Skip to content

Commit fcd1622

Browse files
StefanStojanovicmarco-ippolito
authored andcommitted
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 PR-URL: #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>
1 parent 776becf commit fcd1622

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
@@ -314,7 +314,7 @@ class ProcessWrap : public HandleWrap {
314314
int signal = args[0]->Int32Value(env->context()).FromJust();
315315
#ifdef _WIN32
316316
if (signal != SIGKILL && signal != SIGTERM && signal != SIGINT &&
317-
signal != SIGQUIT) {
317+
signal != SIGQUIT && signal != 0) {
318318
signal = SIGKILL;
319319
}
320320
#endif

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy