GeezerVison is showing github.com — src: add --disable-sigusr1 to prevent signal i/o thread · nodejs/node@48c813f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -573,6 +573,17 @@ Disable the `Object.prototype.__proto__` property. If `mode` is `delete`, the | 573 | 573 | property is removed entirely. If `mode` is `throw`, accesses to the | 574 | 574 | property throw an exception with the code `ERR_PROTO_ACCESS`. | 575 | 575 |
| | 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 | + | 576 | 587 | ### `--disable-warning=code-or-type` | 577 | 588 |
| 578 | 589 | > Stability: 1.1 - Active development | @@ -1471,6 +1482,7 @@ added: v7.6.0 | 1471 | 1482 |
| 1472 | 1483 | Set the `host:port` to be used when the inspector is activated. | 1473 | 1484 | Useful when activating the inspector by sending the `SIGUSR1` signal. | | 1485 | +Except when [`--disable-sigusr1`][] is passed. | 1474 | 1486 |
| 1475 | 1487 | Default host is `127.0.0.1`. If port `0` is specified, | 1476 | 1488 | a random available port will be used. | @@ -3082,6 +3094,7 @@ one is included in the list below. | 3082 | 3094 | * `--conditions`, `-C` | 3083 | 3095 | * `--diagnostic-dir` | 3084 | 3096 | * `--disable-proto` | | 3097 | +* `--disable-sigusr1` | 3085 | 3098 | * `--disable-warning` | 3086 | 3099 | * `--disable-wasm-trap-handler` | 3087 | 3100 | * `--dns-result-order` | @@ -3660,6 +3673,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 | 3660 | 3673 | [`--build-snapshot`]: #--build-snapshot | 3661 | 3674 | [`--cpu-prof-dir`]: #--cpu-prof-dir | 3662 | 3675 | [`--diagnostic-dir`]: #--diagnostic-dirdirectory | | 3676 | +[`--disable-sigusr1`]: #--disable-sigusr1 | 3663 | 3677 | [`--env-file-if-exists`]: #--env-file-if-existsconfig | 3664 | 3678 | [`--env-file`]: #--env-fileconfig | 3665 | 3679 | [`--experimental-addon-modules`]: #--experimental-addon-modules | |
Collapse file Copy file name to clipboardExpand all lines: src/env-inl.h +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -666,7 +666,8 @@ inline bool Environment::no_global_search_paths() const { | 666 | 666 | } | 667 | 667 |
| 668 | 668 | 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; | 670 | 671 | } | 671 | 672 |
| 672 | 673 | inline bool Environment::no_browser_globals() const { | |
Collapse file Copy file name to clipboardExpand all lines: src/node_options.cc +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -386,6 +386,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | 386 | 386 | " (default: current working directory)", | 387 | 387 | &EnvironmentOptions::diagnostic_dir, | 388 | 388 | kAllowedInEnvvar); | | 389 | + AddOption("--disable-sigusr1", | | 390 | + "Disable inspector thread to be listening for SIGUSR1 signal", | | 391 | + &EnvironmentOptions::disable_sigusr1, | | 392 | + kAllowedInEnvvar, | | 393 | + false); | 389 | 394 | AddOption("--dns-result-order", | 390 | 395 | "set default value of verbatim in dns.lookup. Options are " | 391 | 396 | "'ipv4first' (IPv4 addresses are placed before IPv6 addresses) " | |
Collapse file Copy file name to clipboardExpand all lines: src/node_options.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -116,6 +116,7 @@ class EnvironmentOptions : public Options { | 116 | 116 | bool abort_on_uncaught_exception = false; | 117 | 117 | std::vector<std::string> conditions; | 118 | 118 | bool detect_module = true; | | 119 | + bool disable_sigusr1 = false; | 119 | 120 | bool print_required_tla = false; | 120 | 121 | bool require_module = true; | 121 | 122 | std::string dns_result_order; | |
Collapse file Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +console.log('pid is', process.pid); | | 2 | +setInterval(() => {}, 1000); |
Collapse file Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | +}); |
|