Skip to content

Commit 1b2bfa0

Browse files
committed
src: allow preventing debug signal handler start
1 parent ecd385e commit 1b2bfa0

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/env-inl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ inline bool Environment::no_global_search_paths() const {
693693
!options_->global_search_paths;
694694
}
695695

696+
inline bool Environment::should_start_debug_signal_handler() const {
697+
return (flags_ & EnvironmentFlags::kNoStartDebugSignalHandler) == 0;
698+
}
699+
696700
inline bool Environment::no_browser_globals() const {
697701
// configure --no-browser-globals
698702
#ifdef NODE_NO_BROWSER_GLOBALS

src/env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ class Environment : public MemoryRetainer {
772772
inline bool tracks_unmanaged_fds() const;
773773
inline bool hide_console_windows() const;
774774
inline bool no_global_search_paths() const;
775+
inline bool should_start_debug_signal_handler() const;
775776
inline bool no_browser_globals() const;
776777
inline uint64_t thread_id() const;
777778
inline worker::Worker* worker_context() const;

src/inspector_agent.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,10 @@ bool Agent::Start(const std::string& path,
696696
StartIoThreadAsyncCallback));
697697
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
698698
start_io_thread_async.data = this;
699-
// Ignore failure, SIGUSR1 won't work, but that should not block node start.
700-
StartDebugSignalHandler();
699+
if (parent_env_->should_start_debug_signal_handler()) {
700+
// Ignore failure, SIGUSR1 won't work, but that should not block node start.
701+
StartDebugSignalHandler();
702+
}
701703

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

src/node.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,11 @@ enum Flags : uint64_t {
649649
// This control is needed by embedders who may not want to initialize the V8
650650
// inspector in situations where one has already been created,
651651
// e.g. Blink's in Chromium.
652-
kNoCreateInspector = 1 << 9
652+
kNoCreateInspector = 1 << 9,
653+
// Controls where or not the InspectorAgent for this Environment should
654+
// call StartDebugSignalHandler. This control is needed by embedders who may
655+
// not want to allow other processes to start the V8 inspector.
656+
kNoStartDebugSignalHandler = 1 << 10
653657
};
654658
} // namespace EnvironmentFlags
655659

0 commit comments

Comments
 (0)