| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1714,10 +1714,14 @@ may not actually terminate the process. | |||
| 1714 | 1714 | ||
| 1715 | 1715 | See kill(2) for reference. | |
| 1716 | 1716 | ||
| 1717 | - On Windows, where POSIX signals do not exist, the `signal` argument will be | ||
| 1718 | - ignored except for `'SIGKILL'`, `'SIGTERM'`, `'SIGINT'` and `'SIGQUIT'`, and the | ||
| 1719 | - process will always be killed forcefully and abruptly (similar to `'SIGKILL'`). | ||
| 1720 | - See [Signal Events][] for more details. | ||
| 1717 | + On Windows, where POSIX signals do not exist, signals are handled as follows. | ||
| 1718 | + `'SIGKILL'`, `'SIGTERM'`, `'SIGINT'` and `'SIGQUIT'` terminate the process | ||
| 1719 | + forcefully and abruptly (similar to `'SIGKILL'`); any other signal whose name is | ||
| 1720 | + known on Windows (such as `'SIGHUP'`) does the same. `'SIGWINCH'` is not | ||
| 1721 | + terminal and is not coerced: `subprocess.kill()` throws an `ENOSYS` error and | ||
| 1722 | + the child keeps running. A signal name that does not exist on Windows (such as | ||
| 1723 | + `'SIGSTOP'`) throws an `ERR_UNKNOWN_SIGNAL` error. See [Signal Events][] for more | ||
| 1724 | + details. | ||
| 1721 | 1725 | ||
| 1722 | 1726 | On Linux, child processes of child processes will not be terminated | |
| 1723 | 1727 | when attempting to kill their parent. This is likely to happen when running a | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -351,7 +351,7 @@ class ProcessWrap : public HandleWrap { | |||
| 351 | 351 | } | |
| 352 | 352 | #ifdef _WIN32 | |
| 353 | 353 | if (signal != SIGKILL && signal != SIGTERM && signal != SIGINT && | |
| 354 | - signal != SIGQUIT && signal != 0) { | ||
| 354 | + signal != SIGQUIT && signal != 0 && signal != SIGWINCH) { | ||
| 355 | 355 | signal = SIGKILL; | |
| 356 | 356 | } | |
| 357 | 357 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { spawn } = require('child_process'); | ||
| 5 | + | ||
| 6 | + // SIGWINCH is a non-terminal signal: sending it must not terminate the target | ||
| 7 | + // process. On Windows, kill() must surface ENOSYS instead of coercing | ||
| 8 | + // SIGWINCH into a SIGKILL (which would wrongly terminate the process). | ||
| 9 | + // Refs: https://github.com/nodejs/node/issues/64324 | ||
| 10 | + | ||
| 11 | + const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)']); | ||
| 12 | + | ||
| 13 | + // The process must survive the SIGWINCH; it is only ever torn down by the | ||
| 14 | + // explicit SIGKILL in the cleanup below (after the listener is removed). | ||
| 15 | + child.on('exit', common.mustNotCall('child must survive SIGWINCH')); | ||
| 16 | + | ||
| 17 | + child.on('spawn', common.mustCall(() => { | ||
| 18 | + if (common.isWindows) { | ||
| 19 | + assert.throws(() => child.kill('SIGWINCH'), { code: 'ENOSYS' }); | ||
| 20 | + } else { | ||
| 21 | + assert.strictEqual(child.kill('SIGWINCH'), true); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + assert.strictEqual(child.signalCode, null); | ||
| 25 | + assert.strictEqual(child.exitCode, null); | ||
| 26 | + | ||
| 27 | + setTimeout(common.mustCall(() => { | ||
| 28 | + assert.strictEqual(child.signalCode, null); | ||
| 29 | + assert.strictEqual(child.exitCode, null); | ||
| 30 | + | ||
| 31 | + child.removeAllListeners('exit'); | ||
| 32 | + child.kill('SIGKILL'); | ||
| 33 | + }), common.platformTimeout(500)); | ||
| 34 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments