-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Unexpected child_process + stdout behavior change from 0.6.5 to 0.6.6 #2507
Comments
13324bf seems to be the commit that breaks your test case. Will investigate. |
On Windows I get the following message. Is that the same as you guys?
The code using to test: var spawn = require('child_process').spawn;
spawn('node', ['-e', 'setTimeout(function(){console.log("fooo");}, 2000)'], {customFds:[-1,-1,2]});
process.exit(0); |
Yes. The error is thrown by the child process. |
Apparently the fd that the child process uses becomes invalid because the master dies (this is expected). After a stdout write fails, net.js tries to close it with an error status. However closing stdout is now forbidden and makes the program crash. |
Can we just have that error not crash the program? Ie, instead of throwing, just do nothing? |
I believe this was done to make it explicit that closing stdout/stderr shouldn't be done (if it's just a noop then people would wrongfully assume that underlying handle actually got closed). Perhaps net.js should try looking at this._isStdio, and not try to close it if it's stdio handle? |
…treams Also, if an error is already provided, then raise the provided error, rather than throwing it with a less helpful 'stdout cannot be closed' message. This is important for properly handling EPIPEs.
When starting a child process with spawn, a self-exit from the parent process and a subsequent write to stdout from the child causes the child to crash unexpectedly. Bug emerged in 0.6.6, Linux x64.
Observed when running process.js:
process.js
child.js
grandchild.js
The text was updated successfully, but these errors were encountered: