Skip to content

Commit 9512839

Browse files
codebyteremarco-ippolito
authored andcommittedJun 17, 2024
src: allow preventing debug signal handler start
PR-URL: #46681 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e62c6e2 commit 9512839

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed
 

‎src/env-inl.h

+4
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ inline bool Environment::no_global_search_paths() const {
677677
!options_->global_search_paths;
678678
}
679679

680+
inline bool Environment::should_start_debug_signal_handler() const {
681+
return (flags_ & EnvironmentFlags::kNoStartDebugSignalHandler) == 0;
682+
}
683+
680684
inline bool Environment::no_browser_globals() const {
681685
// configure --no-browser-globals
682686
#ifdef NODE_NO_BROWSER_GLOBALS

‎src/env.h

+1
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ class Environment : public MemoryRetainer {
801801
inline bool tracks_unmanaged_fds() const;
802802
inline bool hide_console_windows() const;
803803
inline bool no_global_search_paths() const;
804+
inline bool should_start_debug_signal_handler() const;
804805
inline bool no_browser_globals() const;
805806
inline uint64_t thread_id() const;
806807
inline worker::Worker* worker_context() const;

‎src/inspector_agent.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,11 @@ bool Agent::Start(const std::string& path,
717717
StartIoThreadAsyncCallback));
718718
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
719719
start_io_thread_async.data = this;
720-
// Ignore failure, SIGUSR1 won't work, but that should not block node start.
721-
StartDebugSignalHandler();
720+
if (parent_env_->should_start_debug_signal_handler()) {
721+
// Ignore failure, SIGUSR1 won't work, but that should not block node
722+
// start.
723+
StartDebugSignalHandler();
724+
}
722725

723726
parent_env_->AddCleanupHook([](void* data) {
724727
Environment* env = static_cast<Environment*>(data);

‎src/node.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,11 @@ enum Flags : uint64_t {
657657
// This control is needed by embedders who may not want to initialize the V8
658658
// inspector in situations where one has already been created,
659659
// e.g. Blink's in Chromium.
660-
kNoCreateInspector = 1 << 9
660+
kNoCreateInspector = 1 << 9,
661+
// Controls where or not the InspectorAgent for this Environment should
662+
// call StartDebugSignalHandler. This control is needed by embedders who may
663+
// not want to allow other processes to start the V8 inspector.
664+
kNoStartDebugSignalHandler = 1 << 10
661665
};
662666
} // namespace EnvironmentFlags
663667

0 commit comments

Comments
 (0)
Please sign in to comment.