-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child Process: fork stdio option doesn't support the String variant that spawn does #10793
Comments
Inconsistent and annoying, but documented, for what that's worth:
|
@sam-github I see what you mean but this doesn't solve the problem. var child = childProcess.fork('./userapp/test.js', config.project.args, {
stdio: [0,1,2,'ipc']
});
console.log('stdio', child.stdio); still the same output as before. Also replacing |
@SEUH as-expected.
|
@sam-github I still don't get it. Am i missing something? If i set |
And to be clear: not-a-problem child.stdio exists so that the parent and read and write data to the child's stdio. It isn't possible to write child to a child's input, if the child is getting input from a tty, or an explicit fd, or anything other than if the child is reading input from a pipe connected to the parent. Same for output: the data the child writes to its stdout or stderr can be read by the parent only if the child's stdout or stderr is connected via a pipe to the parent. So the docs don't just describe an arbitary limitation, bug, or missing feature. They describe a natural behaviour. Note that your original description attempted to pipe the child's stdio using |
Works for me. Provide a standalone runnable example if you don't think it works. |
@sam-github Found the problem...i provided empty var child = childProcess.fork('./userapp/test.js', config.project.args, {
stdio: ['pipe','pipe','pipe','ipc']
});
console.log('stdio', child.stdio);
|
Now that is a bug, IMO:
Providing null or undefined as the arg array should either type-error, or just mean "no args" - the latter makes more sense to me, but I would have to check the other array args in the child_process API, and make sure that the handling was consistent. I suspect it is assuming there is no options if the args are null/undefined ATM, but haven't looked at the code. |
@sam-github Right...do you open an issue for this? |
If you did I would really appreciate it. Otherwise I will do so later. |
And if you have interest, both the feature and the bug are quite easy to implement, good first contributions. |
@sam-github I can take a stab a this |
@trendsetter37 Can you report the bug, so the bug and the feature are tracked as individual issues? Then say which of the two (both?) you are going to take a stab at. Thanks! |
Sure, I'll report the bug and take a stab at both. |
Add string shortcut option for stdio parameter. PR-URL: nodejs#10866 Fixes: nodejs#10793
Version: v7.4.0
Platform: Windows 64 bit
The following code forks a script but all it's stdio objects are null
index.js
test.js
console output:
Also i've tried to set the childs stdio with
stdio: [stream, stream, stream]
but this didn't work and the child used the parents stream to outputThe text was updated successfully, but these errors were encountered: