From ff22f6b5566b6f15c448b7790e439aea747df257 Mon Sep 17 00:00:00 2001 From: Ederin Igharoro Date: Tue, 8 Oct 2024 10:37:31 -0600 Subject: [PATCH 1/4] doc: add note about stdio streams in child_process --- doc/api/child_process.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 045f34352a92ee..a0c72c13e08b30 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -6,7 +6,7 @@ -The `node:child_process` module provides the ability to spawn subprocesses in +The `node:child_process` module provides the ability to spawn subprocesses inf a manner that is similar, but not identical, to popen(3). This capability is primarily provided by the [`child_process.spawn()`][] function: @@ -1061,6 +1061,9 @@ pipes between the parent and child. The value is one of the following: corresponds to the index in the `stdio` array. The stream must have an underlying descriptor (file streams do not start until the `'open'` event has occurred). + **NOTE:** You cannot pass `stdin` as a writable or `stdout`/`stderr` as readable + under `options.stdio`. If you do so on a stream object, there is no guarantee + that the callback will be called. If the stream errors, all callbacks will be dropped. 7. Positive integer: The integer value is interpreted as a file descriptor that is open in the parent process. It is shared with the child process, similar to how {Stream} objects can be shared. Passing sockets From 7c826ab513e919571b5b80fda62f8b0962e1442b Mon Sep 17 00:00:00 2001 From: Ederin Igharoro Date: Tue, 8 Oct 2024 10:47:49 -0600 Subject: [PATCH 2/4] refactor(child_process): fix typo error --- doc/api/child_process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index a0c72c13e08b30..4fa69573c85b88 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -6,7 +6,7 @@ -The `node:child_process` module provides the ability to spawn subprocesses inf +The `node:child_process` module provides the ability to spawn subprocesses in a manner that is similar, but not identical, to popen(3). This capability is primarily provided by the [`child_process.spawn()`][] function: From 7480ee89a13a22b421e5667ba43fffda9c3aa403 Mon Sep 17 00:00:00 2001 From: Ederin Igharoro Date: Tue, 8 Oct 2024 11:42:54 -0600 Subject: [PATCH 3/4] refactor(child_process): update docs for the stream object --- doc/api/child_process.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 4fa69573c85b88..33d9ce844a8fda 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1061,9 +1061,15 @@ pipes between the parent and child. The value is one of the following: corresponds to the index in the `stdio` array. The stream must have an underlying descriptor (file streams do not start until the `'open'` event has occurred). - **NOTE:** You cannot pass `stdin` as a writable or `stdout`/`stderr` as readable - under `options.stdio`. If you do so on a stream object, there is no guarantee - that the callback will be called. If the stream errors, all callbacks will be dropped. + **NOTE:** While it is technically possible to pass `stdin` as a writable or + `stdout`/`stderr` as readable under `options.stdio`, it is not recommended. + Readable and writable streams are designed with distinct behaviors, and using + them incorrectly (e.g., passing a readable stream where a writable stream is + expected) can lead to unexpected results or errors. This practice is discouraged + as it may result in undefined behavior or dropped callbacks if the stream + encounters errors. Always ensure that `stdin` is used as writable and + `stdout`/`stderr` as readable to maintain the intended flow of data between + the parent and child processes. 7. Positive integer: The integer value is interpreted as a file descriptor that is open in the parent process. It is shared with the child process, similar to how {Stream} objects can be shared. Passing sockets From 99a235151fd15d9350ec940ae31f6fb3861c6b32 Mon Sep 17 00:00:00 2001 From: Ederin Igharoro Date: Tue, 8 Oct 2024 15:46:19 -0600 Subject: [PATCH 4/4] doc: add note about stdio streams in child_process --- doc/api/child_process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 33d9ce844a8fda..f70d96a3395300 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1062,7 +1062,7 @@ pipes between the parent and child. The value is one of the following: underlying descriptor (file streams do not start until the `'open'` event has occurred). **NOTE:** While it is technically possible to pass `stdin` as a writable or - `stdout`/`stderr` as readable under `options.stdio`, it is not recommended. + `stdout`/`stderr` as readable, it is not recommended. Readable and writable streams are designed with distinct behaviors, and using them incorrectly (e.g., passing a readable stream where a writable stream is expected) can lead to unexpected results or errors. This practice is discouraged