Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/process_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/parallel/test-child-process-kill.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,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