-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Cannot work with stdin in a sub-subprocess with require('child_process').fork() #3240
Comments
There are a few bugs inpix.
However, this error isn't seen, because the stderr from the worker in server.js is not ever examined, and Pix's server.js doesn't examine the exit code in the AFAICT, everything in node is operating as designed. However, it would be nice if the env was handled the same way by fork as it is by spawn. |
I made a gist to demonstrate the issue more cleanly and to show that this is not a problem with the environment variables: The worker.js is getting run because |
After some analysis, I've concluded that I agree with @isaacs; everything in node is operating as designed. Because the environment isn't cleared before This value then gets to the third process: The code works as intended if we simply clear the environment in var ps = spawn(process.execPath, ['worker.js' ], {env: {}}); It may, however, be reasonable to clear |
What @russfrank said, the inherited |
* windows: skip GetFileAttributes call when opening a file (Bert Belder) * crypto: add PKCS12/PFX support (Sambasiva Suda) * #3240: child_process: delete NODE_CHANNEL_FD from env in spawn (Ben Noordhuis) * windows: add test for path.normalize with UNC paths (Bert Belder) * windows: make path.normalize convert all slashes to backslashes (Bert Belder) * fs: Automatically close FSWatcher on error (Bert Belder) * #3258: fs.ReadStream.pause() emits duplicate data event (koichik) * pipe_wrap: don't assert() on pipe accept errors (Ben Noordhuis) * Better exception output for module load and process.nextTick (Felix Geisendörfer) * zlib: fix error reporting (Ben Noordhuis) * http: Don't destroy on timeout (isaacs) * #3231: http: Don't try to emit error on a null'ed req object (isaacs) * #3236: http: Refactor ClientRequest.onSocket (isaacs)
* windows: skip GetFileAttributes call when opening a file (Bert Belder) * crypto: add PKCS12/PFX support (Sambasiva Suda) * #3240: child_process: delete NODE_CHANNEL_FD from env in spawn (Ben Noordhuis) * windows: add test for path.normalize with UNC paths (Bert Belder) * windows: make path.normalize convert all slashes to backslashes (Bert Belder) * fs: Automatically close FSWatcher on error (Bert Belder) * #3258: fs.ReadStream.pause() emits duplicate data event (koichik) * pipe_wrap: don't assert() on pipe accept errors (Ben Noordhuis) * Better exception output for module load and process.nextTick (Felix Geisendörfer) * zlib: fix error reporting (Ben Noordhuis) * http: Don't destroy on timeout (isaacs) * #3231: http: Don't try to emit error on a null'ed req object (isaacs) * #3236: http: Refactor ClientRequest.onSocket (isaacs)
I'm pretty sure this is a bug. @substack and I spent some time tracking this down when his application wouldn't deploy to nodejitsu:
Reproduce it
In (2) I added a layer of indirection which spawns
server.js
, once with.fork()
and once with.spawn()
.Here's a quick rundown of the process tree(s):
node server.js
node spawn.js
So just that one level of indirection with .fork() breaks all piping of process.stdin.
@piscisaureus @isaacs @bnoordhuis You guys have any thoughts here? I'm stumped why this is happening, but I know it is.
The text was updated successfully, but these errors were encountered: