mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
src: fix kill signal 0 on Windows
This special case was missed in the previous changes to this file. Refs: https://github.com/nodejs/node/pull/55514 Refs: https://github.com/nodejs/node/issues/42923 Fixes: https://github.com/nodejs/node/issues/57669 PR-URL: https://github.com/nodejs/node/pull/57695 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
parent
870dec25f7
commit
32e5e815ef
|
|
@ -385,7 +385,7 @@ class ProcessWrap : public HandleWrap {
|
|||
}
|
||||
#ifdef _WIN32
|
||||
if (signal != SIGKILL && signal != SIGTERM && signal != SIGINT &&
|
||||
signal != SIGQUIT) {
|
||||
signal != SIGQUIT && signal != 0) {
|
||||
signal = SIGKILL;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -58,3 +58,23 @@ if (common.isWindows) {
|
|||
});
|
||||
process.kill('SIGHUP');
|
||||
}
|
||||
|
||||
// Test that the process is not killed when sending a 0 signal.
|
||||
// This is a no-op signal that is used to check if the process is alive.
|
||||
const code = `const interval = setInterval(() => {}, 1000);
|
||||
process.stdin.on('data', () => { clearInterval(interval); });
|
||||
process.stdout.write('x');`;
|
||||
|
||||
const checkProcess = spawn(process.execPath, ['-e', code]);
|
||||
|
||||
checkProcess.on('exit', (code, signal) => {
|
||||
assert.strictEqual(code, 0);
|
||||
assert.strictEqual(signal, null);
|
||||
});
|
||||
|
||||
checkProcess.stdout.on('data', common.mustCall((chunk) => {
|
||||
assert.strictEqual(chunk.toString(), 'x');
|
||||
checkProcess.kill(0);
|
||||
checkProcess.stdin.write('x');
|
||||
checkProcess.stdin.end();
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user