child_process: support stdio option in fork() by cjihrig · Pull Request #7811 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/api/child_process.md
12 changes: 8 additions & 4 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ exports.fork = function(modulePath /*, args, options*/) {

args = execArgv.concat([modulePath], args);

// Leave stdin open for the IPC channel. stdout and stderr should be the
// same as the parent's if silent isn't set.
options.stdio = options.silent ? ['pipe', 'pipe', 'pipe', 'ipc'] :
[0, 1, 2, 'ipc'];
if (!Array.isArray(options.stdio)) {
// Leave stdin open for the IPC channel. stdout and stderr should be the
// same as the parent's if silent isn't set.
options.stdio = options.silent ? ['pipe', 'pipe', 'pipe', 'ipc'] :
[0, 1, 2, 'ipc'];
} else if (options.stdio.indexOf('ipc') === -1) {
throw new TypeError('Forked processes must have an IPC channel');
}

options.execPath = options.execPath || process.execPath;

Expand Down
54 changes: 54 additions & 0 deletions test/parallel/test-child-process-fork-stdio.js