doc: add require() lines to child.stdio example

PR-URL: https://github.com/iojs/io.js/pull/1504
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
pull/1594/head
Nick Raienko 2015-04-22 14:58:04 +03:00 committed by Brendan Ashworth
parent 2e2fce0502
commit 2a3a1909ab
1 changed files with 6 additions and 2 deletions

View File

@ -144,11 +144,15 @@ In the following example, only the child's fd `1` is setup as a pipe, so only
the parent's `child.stdio[1]` is a stream, all other values in the array are the parent's `child.stdio[1]` is a stream, all other values in the array are
`null`. `null`.
child = child_process.spawn("ls", { var assert = require('assert');
var fs = require('fs');
var child_process = require('child_process');
child = child_process.spawn('ls', {
stdio: [ stdio: [
0, // use parents stdin for child 0, // use parents stdin for child
'pipe', // pipe child's stdout to parent 'pipe', // pipe child's stdout to parent
fs.openSync("err.out", "w") // direct child's stderr to a file fs.openSync('err.out', 'w') // direct child's stderr to a file
] ]
}); });