Skip to content

Commit dccec3f

Browse files
thw0rtedvsemozhetbyt
authored andcommitted
doc: document 'inherit' option for stdio (non-shorthand)
PR-URL: #22309 Fixes: #22297 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent fc84666 commit dccec3f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doc/api/child_process.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,7 @@ For convenience, `options.stdio` may be one of the following strings:
599599

600600
* `'pipe'` - equivalent to `['pipe', 'pipe', 'pipe']` (the default)
601601
* `'ignore'` - equivalent to `['ignore', 'ignore', 'ignore']`
602-
* `'inherit'` - equivalent to `[process.stdin, process.stdout, process.stderr]`
603-
or `[0,1,2]`
602+
* `'inherit'` - equivalent to `['inherit', 'inherit', 'inherit']` or `[0, 1, 2]`
604603

605604
Otherwise, the value of `options.stdio` is an array where each index corresponds
606605
to an fd in the child. The fds 0, 1, and 2 correspond to stdin, stdout,
@@ -626,16 +625,20 @@ pipes between the parent and child. The value is one of the following:
626625
will always open fds 0 - 2 for the processes it spawns, setting the fd to
627626
`'ignore'` will cause Node.js to open `/dev/null` and attach it to the
628627
child's fd.
629-
4. {Stream} object - Share a readable or writable stream that refers to a tty,
628+
4. `'inherit'` - Pass through the corresponding stdio stream to/from the
629+
parent process. In the first three positions, this is equivalent to
630+
`process.stdin`, `process.stdout`, and `process.stderr`, respectively. In
631+
any other position, equivalent to `'ignore'`.
632+
5. {Stream} object - Share a readable or writable stream that refers to a tty,
630633
file, socket, or a pipe with the child process. The stream's underlying
631634
file descriptor is duplicated in the child process to the fd that
632635
corresponds to the index in the `stdio` array. Note that the stream must
633636
have an underlying descriptor (file streams do not until the `'open'`
634637
event has occurred).
635-
5. Positive integer - The integer value is interpreted as a file descriptor
638+
6. Positive integer - The integer value is interpreted as a file descriptor
636639
that is currently open in the parent process. It is shared with the child
637640
process, similar to how {Stream} objects can be shared.
638-
6. `null`, `undefined` - Use default value. For stdio fds 0, 1, and 2 (in other
641+
7. `null`, `undefined` - Use default value. For stdio fds 0, 1, and 2 (in other
639642
words, stdin, stdout, and stderr) a pipe is created. For fd 3 and up, the
640643
default is `'ignore'`.
641644

0 commit comments

Comments
 (0)