Skip to content

Commit 04b41bd

Browse files
Ed-roroaduh95
authored andcommitted
doc: add note about stdio streams in child_process
PR-URL: #55322 Fixes: #15714 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 689d3a3 commit 04b41bd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/api/child_process.md

+9
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,15 @@ pipes between the parent and child. The value is one of the following:
10611061
corresponds to the index in the `stdio` array. The stream must have an
10621062
underlying descriptor (file streams do not start until the `'open'` event has
10631063
occurred).
1064+
**NOTE:** While it is technically possible to pass `stdin` as a writable or
1065+
`stdout`/`stderr` as readable, it is not recommended.
1066+
Readable and writable streams are designed with distinct behaviors, and using
1067+
them incorrectly (e.g., passing a readable stream where a writable stream is
1068+
expected) can lead to unexpected results or errors. This practice is discouraged
1069+
as it may result in undefined behavior or dropped callbacks if the stream
1070+
encounters errors. Always ensure that `stdin` is used as writable and
1071+
`stdout`/`stderr` as readable to maintain the intended flow of data between
1072+
the parent and child processes.
10641073
7. Positive integer: The integer value is interpreted as a file descriptor
10651074
that is open in the parent process. It is shared with the child
10661075
process, similar to how {Stream} objects can be shared. Passing sockets

0 commit comments

Comments
 (0)