File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+ } ) ) ;
You can’t perform that action at this time.
0 commit comments