You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Child Process: fork stdio option doesn't support the String variant that spawn does #10793
changed the title [-]Child Process: all stdio streams are null[/-][+]Child Process: fork stdio option doesn't support the String variant that spawn does[/+]on Jan 13, 2017
A sparse array of pipes to the child process, corresponding with positions in the stdio option passed to child_process.spawn() that have been set to the value 'pipe'.
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 'pipe'. That is a missing feature, because in spawn, that string value is a short-hand for ['pipe', 'pipe', 'pipe']. Your example above isn't equivalent, its the equivalent of what spawn would do with stdio: 'inherit' (also a feature missing from fork(), of course), and very different from 'pipe'.
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.
@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!
Activity
sam-github commentedon Jan 13, 2017
Inconsistent and annoying, but documented, for what that's worth:
[-]Child Process: all stdio streams are null[/-][+]Child Process: fork stdio option doesn't support the String variant that spawn does[/+]SEUH commentedon Jan 13, 2017
@sam-github I see what you mean but this doesn't solve the problem.
Even with the array version provided and 'ipc', it doesn't work
still the same output as before. Also replacing
0,1,2withwriteable streamsdoesn't worksam-github commentedon Jan 13, 2017
@SEUH as-expected.
SEUH commentedon Jan 13, 2017
@sam-github I still don't get it. Am i missing something? If i set
stdio: ['pipe','pipe','pipe','ipc']stdio's are still nullsam-github commentedon Jan 13, 2017
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
'pipe'. That is a missing feature, because in spawn, that string value is a short-hand for['pipe', 'pipe', 'pipe']. Your example above isn't equivalent, its the equivalent of what spawn would do withstdio: 'inherit'(also a feature missing fromfork(), of course), and very different from'pipe'.sam-github commentedon Jan 13, 2017
Works for me. Provide a standalone runnable example if you don't think it works.
SEUH commentedon Jan 13, 2017
@sam-github Found the problem...i provided empty
argsconfig.project.argswasnull.sam-github commentedon Jan 13, 2017
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.
SEUH commentedon Jan 13, 2017
@sam-github Right...do you open an issue for this?
sam-github commentedon Jan 13, 2017
If you did I would really appreciate it. Otherwise I will do so later.
sam-github commentedon Jan 13, 2017
And if you have interest, both the feature and the bug are quite easy to implement, good first contributions.
trendsetter37 commentedon Jan 13, 2017
@sam-github I can take a stab a this
sam-github commentedon Jan 13, 2017
@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!
trendsetter37 commentedon Jan 14, 2017
Sure, I'll report the bug and take a stab at both.
child_process: add string shortcut for fork stdio