diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 6d19c7184c3020..52e3759403b5fa 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -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 diff --git a/test/parallel/test-child-process-kill.js b/test/parallel/test-child-process-kill.js index 3fa2cac0d455e2..8622153fc6f03b 100644 --- a/test/parallel/test-child-process-kill.js +++ b/test/parallel/test-child-process-kill.js @@ -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(); +}));