summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <sam@strongloop.com>2014-01-08 17:16:17 -0800
committerFedor Indutny <fedor.indutny@gmail.com>2014-01-13 21:36:56 +0000
commit7bd6e333182c9d45a7376092c861d746592bf62b (patch)
treeceaeb70bb9dcda83e4dfdcc071d2ca27b454743f
parent1b74892807887fe89828ab874e9ce6b2831e7d54 (diff)
downloadnode-7bd6e333182c9d45a7376092c861d746592bf62b.tar.gz
doc: streams must be open to be passed to child
spawn stdio options can be a 'stream', but the following code fails with "Incorrect value for stdio stream: [object Object]", despite being a stream. The problem is the test isn't really for a stream, its for an object with a numeric `.fd` property, and streams do not have an fd until their async 'open' event has occurred. This is reasonable, but was not documented. child_process.spawn('date', [], {stdio: [ 'ignore', fs.createWriteStream('out.txt',{flags:'a'}), 'ignore']})
-rw-r--r--doc/api/child_process.markdown4
1 files changed, 3 insertions, 1 deletions
diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown
index f9adadc18..7f5958f54 100644
--- a/doc/api/child_process.markdown
+++ b/doc/api/child_process.markdown
@@ -411,7 +411,9 @@ index corresponds to a fd in the child. The value is one of the following:
4. `Stream` object - Share a readable or writable stream that refers to a tty,
file, socket, or a pipe with the child process. The stream's underlying
file descriptor is duplicated in the child process to the fd that
- corresponds to the index in the `stdio` array.
+ corresponds to the index in the `stdio` array. Note that the stream must
+ have an underlying descriptor (file streams do not until the `'open'`
+ event has occurred).
5. Positive integer - The integer value is interpreted as a file descriptor
that is is currently open in the parent process. It is shared with the child
process, similar to how `Stream` objects can be shared.