Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

child_process: describe how to open fd in child #8624

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 7 additions & 4 deletions doc/api/child_process.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,12 @@ The 'stdio' option to `child_process.spawn()` is an array where each
index corresponds to a fd in the child. The value is one of the following:

1. `'pipe'` - Create a pipe between the child process and the parent process.
The parent end of the pipe is exposed to the parent as a property on the
`child_process` object as `ChildProcess.stdio[fd]`. Pipes created for
fds 0 - 2 are also available as ChildProcess.stdin, ChildProcess.stdout
and ChildProcess.stderr, respectively.
Pipes created for fds 0 - 2 are already opened in the child and each is
available in the child as ChildProcess.stdin, ChildProcess.stdout and
ChildProcess.stderr, respectively. The parent end of all pipes is exposed to
the parent as a property on the `child_process` object as
`ChildProcess.stdio[fd]`. Fd's greater than 2 can be opened in the child
using a new [net.Socket][].

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have typos in the above, link markdown that doesn't work, use of ChildProcess.stdin when you mean child's process.stdin, and describing a fd as being "opened", which is not correct.

But your essential point is valid, and the docs are terrible, I've addressed your specific concern and others in #8639

2. `'ipc'` - Create an IPC channel for passing messages/file descriptors
between parent and child. A ChildProcess may have at most *one* IPC stdio
file descriptor. Setting this option enables the ChildProcess.send() method.
Expand Down Expand Up @@ -690,3 +692,4 @@ throw. The `Error` object will contain the entire result from
[`child_process.spawnSync`](#child_process_child_process_spawnsync_command_args_options)

[EventEmitter]: events.html#events_class_events_eventemitter
[net.Socket]: net.html#net_class_net_socket