-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Closed
Labels
libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.

Description
- Version: v10.10.0
- Platform: Windows x64
parent.js
require('child_process').spawn('node', ['child.js'], {
stdio: 'inherit',
});
child.js
const doNothing = () => {};
process.stdin.on('data', doNothing);
require('child_process').spawn('node', ['-v']).on('exit', () => {
process.stdin.unref();
console.log('After printing this, the process should exit');
});
Run with node parent.js
Results
Linux: The process terminates by itself
Mac: The process terminates by itself
Windows: The process keeps running until Enter is pressed
This strange behavior seems to break some npm modules.
Other details
Adding process.stdin.removeListener('data', doNothing)
or process.stdin.removeAllListeners('data')
before unref
doesn't make any difference.
When enter is pressed, it doesn't trigger data
callback, just terminates the process.
Edit
Simplified code:
// parent.js
process.stdin.on('data', () => {});
setTimeout(() => {
process.stdin.unref();
console.log('After printing this, the process should exit');
});
Here we don't have a child process. Run with node parent.js
Results on windows
50% of times - the process exits
50% of times - the process keeps running
Metadata
Metadata
Assignees
Labels
libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.