Version
v24.19.0, v26.6.0
Platform
Subsystem
node:child_process
What steps will reproduce the bug?
Running .kill('SIGTERM') on an invalid child_process spawn results in the termination of the main Node.js process (the caller)
For instance, running require('child_process').spawn('whoami').kill('SIGTERM');.
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior? Why is that the expected behavior?
Node.js should abort killing since .pid will be 0.
Original Issue
Version
v24.18.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Hi,
I would like to report a bug that happens only on macOS. When run the code snippet below, the main process gets terminated:
var {spawn} = require('child_process');
Array.prototype[Symbol.iterator] = function* () {};
var proc = spawn("ts-node", ["--version"]); //or any other non-OS native command, e.g., brew --version
console.log("subprocess forked");
proc.kill('SIGTERM');
console.log("Killed Subprocess");
How often does it reproduce? Is there a required condition?
It's a permanent effect
What is the expected behavior? Why is that the expected behavior?
To kill the child process only
What do you see instead?
I get the following output:
subprocess forked
zsh: terminated node test.js
Additional information
No response
Tip
Rewritten by @avivkeller
Version
v24.19.0, v26.6.0
Platform
Subsystem
node:child_processWhat steps will reproduce the bug?
Running
.kill('SIGTERM')on an invalidchild_processspawn results in the termination of the main Node.js process (the caller)For instance, running
require('child_process').spawn('whoami').kill('SIGTERM');.How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior? Why is that the expected behavior?
Node.js should abort killing since
.pidwill be0.Original Issue
Version
v24.18.0
Platform
Subsystem
No response
What steps will reproduce the bug?
Hi,
I would like to report a bug that happens only on macOS. When run the code snippet below, the main process gets terminated:
How often does it reproduce? Is there a required condition?
It's a permanent effect
What is the expected behavior? Why is that the expected behavior?
To kill the child process only
What do you see instead?
I get the following output:
Additional information
No response