Skip to content

Commit cd81beb

Browse files
src: fix kill signal 0 on Windows
This special case was missed in the previous changes to this file. Refs: #55514 Refs: #42923 Fixes: #57669
1 parent 657f818 commit cd81beb

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/process_wrap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ class ProcessWrap : public HandleWrap {
385385
}
386386
#ifdef _WIN32
387387
if (signal != SIGKILL && signal != SIGTERM && signal != SIGINT &&
388-
signal != SIGQUIT) {
388+
signal != SIGQUIT && signal != 0) {
389389
signal = SIGKILL;
390390
}
391391
#endif

test/parallel/test-child-process-kill.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,23 @@ if (common.isWindows) {
6060
});
6161
process.kill('SIGHUP');
6262
}
63+
64+
// Test that the process is not killed when sending a 0 signal.
65+
// This is a no-op signal that is used to check if the process is alive.
66+
const code = `const interval = setInterval(() => {}, 1000);
67+
process.stdin.on('data', () => { clearInterval(interval); });
68+
process.stdout.write('x');`;
69+
70+
const checkProcess = spawn(process.execPath, ['-e', code]);
71+
72+
checkProcess.on('exit', (code, signal) => {
73+
assert.strictEqual(code, 0);
74+
assert.strictEqual(signal, null);
75+
});
76+
77+
checkProcess.stdout.on('data', common.mustCall((chunk) => {
78+
assert.strictEqual(chunk.toString(), 'x');
79+
checkProcess.kill(0);
80+
checkProcess.stdin.write('x');
81+
checkProcess.stdin.end();
82+
}));

0 commit comments

Comments
 (0)