Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 48c813f

Browse filesBrowse files
RafaelGSSaduh95
authored andcommitted
src: add --disable-sigusr1 to prevent signal i/o thread
This commit adds a new flag `--disable-sigusr1` to prevent the SignalIOThread to be up listening the SIGUSR1 events and then starting the debugging session. PR-URL: #56441 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent df78515 commit 48c813f
Copy full SHA for 48c813f

File tree

Expand file treeCollapse file tree

6 files changed

+50
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+50
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+14Lines changed: 14 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,17 @@ Disable the `Object.prototype.__proto__` property. If `mode` is `delete`, the
573573
property is removed entirely. If `mode` is `throw`, accesses to the
574574
property throw an exception with the code `ERR_PROTO_ACCESS`.
575575

576+
### `--disable-sigusr1`
577+
578+
<!-- YAML
579+
added: REPLACEME
580+
-->
581+
582+
> Stability: 1.2 - Release candidate
583+
584+
Disable the ability of starting a debugging session by sending a
585+
`SIGUSR1` signal to the process.
586+
576587
### `--disable-warning=code-or-type`
577588

578589
> Stability: 1.1 - Active development
@@ -1471,6 +1482,7 @@ added: v7.6.0
14711482

14721483
Set the `host:port` to be used when the inspector is activated.
14731484
Useful when activating the inspector by sending the `SIGUSR1` signal.
1485+
Except when [`--disable-sigusr1`][] is passed.
14741486

14751487
Default host is `127.0.0.1`. If port `0` is specified,
14761488
a random available port will be used.
@@ -3082,6 +3094,7 @@ one is included in the list below.
30823094
* `--conditions`, `-C`
30833095
* `--diagnostic-dir`
30843096
* `--disable-proto`
3097+
* `--disable-sigusr1`
30853098
* `--disable-warning`
30863099
* `--disable-wasm-trap-handler`
30873100
* `--dns-result-order`
@@ -3660,6 +3673,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
36603673
[`--build-snapshot`]: #--build-snapshot
36613674
[`--cpu-prof-dir`]: #--cpu-prof-dir
36623675
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
3676+
[`--disable-sigusr1`]: #--disable-sigusr1
36633677
[`--env-file-if-exists`]: #--env-file-if-existsconfig
36643678
[`--env-file`]: #--env-fileconfig
36653679
[`--experimental-addon-modules`]: #--experimental-addon-modules
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ inline bool Environment::no_global_search_paths() const {
666666
}
667667

668668
inline bool Environment::should_start_debug_signal_handler() const {
669-
return (flags_ & EnvironmentFlags::kNoStartDebugSignalHandler) == 0;
669+
return ((flags_ & EnvironmentFlags::kNoStartDebugSignalHandler) == 0) &&
670+
!options_->disable_sigusr1;
670671
}
671672

672673
inline bool Environment::no_browser_globals() const {
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
386386
" (default: current working directory)",
387387
&EnvironmentOptions::diagnostic_dir,
388388
kAllowedInEnvvar);
389+
AddOption("--disable-sigusr1",
390+
"Disable inspector thread to be listening for SIGUSR1 signal",
391+
&EnvironmentOptions::disable_sigusr1,
392+
kAllowedInEnvvar,
393+
false);
389394
AddOption("--dns-result-order",
390395
"set default value of verbatim in dns.lookup. Options are "
391396
"'ipv4first' (IPv4 addresses are placed before IPv6 addresses) "
Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class EnvironmentOptions : public Options {
116116
bool abort_on_uncaught_exception = false;
117117
std::vector<std::string> conditions;
118118
bool detect_module = true;
119+
bool disable_sigusr1 = false;
119120
bool print_required_tla = false;
120121
bool require_module = true;
121122
std::string dns_result_order;
Collapse file
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
console.log('pid is', process.pid);
2+
setInterval(() => {}, 1000);
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const fixtures = require('../common/fixtures');
5+
const { it } = require('node:test');
6+
const assert = require('node:assert');
7+
const { NodeInstance } = require('../common/inspector-helper.js');
8+
9+
common.skipIfInspectorDisabled();
10+
11+
it('should not attach a debugger with SIGUSR1', { skip: common.isWindows }, async () => {
12+
const file = fixtures.path('disable-signal/sigusr1.js');
13+
const instance = new NodeInstance(['--disable-sigusr1'], undefined, file);
14+
15+
instance.on('stderr', common.mustNotCall());
16+
const loggedPid = await new Promise((resolve) => {
17+
instance.on('stdout', (data) => {
18+
const matches = data.match(/pid is (\d+)/);
19+
if (matches) resolve(Number(matches[1]));
20+
});
21+
});
22+
23+
assert.ok(process.kill(instance.pid, 'SIGUSR1'));
24+
assert.strictEqual(loggedPid, instance.pid);
25+
assert.ok(await instance.kill());
26+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.