@@ -280,9 +280,9 @@ exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
280
280
});
281
281
```
282
282
283
- If ` timeout ` is greater than ` 0 ` , the parent will send the signal
283
+ If ` timeout ` is greater than ` 0 ` , the parent process will send the signal
284
284
identified by the ` killSignal ` property (the default is ` 'SIGTERM' ` ) if the
285
- child runs longer than ` timeout ` milliseconds.
285
+ child process runs longer than ` timeout ` milliseconds.
286
286
287
287
Unlike the exec(3) POSIX system call, ` child_process.exec() ` does not replace
288
288
the existing process and uses a shell to execute the command.
@@ -535,8 +535,8 @@ changes:
535
535
* ` args ` {string\[ ] } List of string arguments.
536
536
* ` options ` {Object}
537
537
* ` cwd ` {string|URL} Current working directory of the child process.
538
- * ` detached ` {boolean} Prepare child to run independently of its parent
539
- process. Specific behavior depends on the platform, see
538
+ * ` detached ` {boolean} Prepare child process to run independently of its
539
+ parent process. Specific behavior depends on the platform, see
540
540
[ ` options.detached ` ] [ ] ).
541
541
* ` env ` {Object} Environment key-value pairs. ** Default:** ` process.env ` .
542
542
* ` execPath ` {string} Executable used to create the child process.
@@ -550,10 +550,11 @@ changes:
550
550
AbortSignal.
551
551
* ` killSignal ` {string|integer} The signal value to be used when the spawned
552
552
process will be killed by timeout or abort signal. ** Default:** ` 'SIGTERM' ` .
553
- * ` silent ` {boolean} If ` true ` , stdin, stdout, and stderr of the child will be
554
- piped to the parent, otherwise they will be inherited from the parent, see
555
- the ` 'pipe' ` and ` 'inherit' ` options for [ ` child_process.spawn() ` ] [ ] 's
556
- [ ` stdio ` ] [ ] for more details. ** Default:** ` false ` .
553
+ * ` silent ` {boolean} If ` true ` , stdin, stdout, and stderr of the child
554
+ process will be piped to the parent process, otherwise they will be inherited
555
+ from the parent process, see the ` 'pipe' ` and ` 'inherit' ` options for
556
+ [ ` child_process.spawn() ` ] [ ] 's [ ` stdio ` ] [ ] for more details.
557
+ ** Default:** ` false ` .
557
558
* ` stdio ` {Array|string} See [ ` child_process.spawn() ` ] [ ] 's [ ` stdio ` ] [ ] .
558
559
When this option is provided, it overrides ` silent ` . If the array variant
559
560
is used, it must contain exactly one item with value ` 'ipc' ` or an error
@@ -686,8 +687,8 @@ changes:
686
687
process. This will be set to ` command` if not specified.
687
688
* ` stdio` {Array|string} Child's stdio configuration (see
688
689
[` options .stdio ` ][` stdio` ]).
689
- * ` detached` {boolean} Prepare child to run independently of its parent
690
- process. Specific behavior depends on the platform, see
690
+ * ` detached` {boolean} Prepare child process to run independently of
691
+ its parent process. Specific behavior depends on the platform, see
691
692
[` options .detached ` ][]).
692
693
* ` uid` {number} Sets the user identity of the process (see setuid(2)).
693
694
* ` gid` {number} Sets the group identity of the process (see setgid(2)).
@@ -909,27 +910,27 @@ added: v0.7.10
909
910
-->
910
911
911
912
On Windows, setting ` options .detached ` to ` true ` makes it possible for the
912
- child process to continue running after the parent exits. The child will have
913
- its own console window. Once enabled for a child process, it cannot be
914
- disabled.
913
+ child process to continue running after the parent exits. The child process
914
+ will have its own console window. Once enabled for a child process,
915
+ it cannot be disabled.
915
916
916
917
On non-Windows platforms, if ` options .detached ` is set to ` true ` , the child
917
918
process will be made the leader of a new process group and session. Child
918
919
processes may continue running after the parent exits regardless of whether
919
920
they are detached or not. See setsid(2) for more information.
920
921
921
- By default, the parent will wait for the detached child to exit. To prevent the
922
- parent from waiting for a given ` subprocess` to exit, use the
923
- ` subprocess .unref ()` method. Doing so will cause the parent's event loop to not
924
- include the child in its reference count, allowing the parent to exit
925
- independently of the child, unless there is an established IPC channel between
926
- the child and the parent.
922
+ By default, the parent will wait for the detached child process to exit.
923
+ To prevent the parent process from waiting for a given ` subprocess` to exit, use
924
+ the ` subprocess .unref ()` method. Doing so will cause the parent process' event
925
+ loop to not include the child process in its reference count, allowing the
926
+ parent process to exit independently of the child process , unless there is an established
927
+ IPC channel between the child and the parent processes .
927
928
928
929
When using the ` detached` option to start a long-running process, the process
929
930
will not stay running in the background after the parent exits unless it is
930
931
provided with a ` stdio` configuration that is not connected to the parent.
931
- If the parent's ` stdio` is inherited, the child will remain attached to the
932
- controlling terminal.
932
+ If the parent process' ` stdio` is inherited, the child process will remain attached
933
+ to the controlling terminal.
933
934
934
935
Example of a long-running process, by detaching and also ignoring its parent
935
936
` stdio` file descriptors, in order to ignore the parent's termination:
@@ -1039,10 +1040,10 @@ pipes between the parent and child. The value is one of the following:
1039
1040
3. ` ' ipc' ` : Create an IPC channel for passing messages/file descriptors
1040
1041
between parent and child. A [` ChildProcess` ][] may have at most one IPC
1041
1042
stdio file descriptor. Setting this option enables the
1042
- [` subprocess .send ()` ][] method. If the child is a Node.js process, the
1043
- presence of an IPC channel will enable [` process .send ()` ][] and
1043
+ [` subprocess .send ()` ][] method. If the child process is a Node.js instance,
1044
+ the presence of an IPC channel will enable [` process .send ()` ][] and
1044
1045
[` process .disconnect ()` ][] methods, as well as [` ' disconnect' ` ][] and
1045
- [` ' message' ` ][] events within the child.
1046
+ [` ' message' ` ][] events within the child process .
1046
1047
1047
1048
Accessing the IPC channel fd in any way other than [` process .send ()` ][]
1048
1049
or using the IPC channel with a child process that is not a Node.js instance
@@ -1109,12 +1110,12 @@ spawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] });
1109
1110
` ` `
1110
1111
1111
1112
_It is worth noting that when an IPC channel is established between the
1112
- parent and child processes, and the child is a Node.js process, the child
1113
- is launched with the IPC channel unreferenced (using ` unref () ` ) until the
1114
- child registers an event handler for the [ ` ' disconnect ' ` ][] event
1115
- or the [` ' message' ` ][] event. This allows the child to exit
1116
- normally without the process being held open by the open IPC channel._
1117
-
1113
+ parent and child processes, and the child process is a Node.js instance,
1114
+ the child process is launched with the IPC channel unreferenced (using
1115
+ ` unref () ` ) until the child process registers an event handler for the
1116
+ [ ` ' disconnect ' ` ][] event or the [` ' message' ` ][] event. This allows the
1117
+ child process to exit normally without the process being held open by the
1118
+ open IPC channel._
1118
1119
See also: [` child_process .exec ()` ][] and [` child_process .fork ()` ][].
1119
1120
1120
1121
## Synchronous process creation
@@ -1437,14 +1438,14 @@ instances of `ChildProcess`.
1437
1438
added: v0.7.7
1438
1439
-->
1439
1440
1440
- * ` code` {number} The exit code if the child exited on its own.
1441
+ * ` code` {number} The exit code if the child process exited on its own.
1441
1442
* ` signal` {string} The signal by which the child process was terminated.
1442
1443
1443
1444
The ` ' close' ` event is emitted after a process has ended _and_ the stdio
1444
1445
streams of a child process have been closed. This is distinct from the
1445
1446
[` ' exit' ` ][] event, since multiple processes might share the same stdio
1446
1447
streams. The ` ' close' ` event will always emit after [` ' exit' ` ][] was
1447
- already emitted, or [` ' error' ` ][] if the child failed to spawn.
1448
+ already emitted, or [` ' error' ` ][] if the child process failed to spawn.
1448
1449
1449
1450
` ` ` cjs
1450
1451
const { spawn } = require (' node:child_process' );
@@ -1515,7 +1516,7 @@ See also [`subprocess.kill()`][] and [`subprocess.send()`][].
1515
1516
added: v0.1.90
1516
1517
-->
1517
1518
1518
- * ` code` {number} The exit code if the child exited on its own.
1519
+ * ` code` {number} The exit code if the child process exited on its own.
1519
1520
* ` signal` {string} The signal by which the child process was terminated.
1520
1521
1521
1522
The ` ' exit' ` event is emitted after the child process ends. If the process
@@ -1625,11 +1626,12 @@ send and receive messages from a child process. When `subprocess.connected` is
1625
1626
added: v0.7.2
1626
1627
-->
1627
1628
1628
- Closes the IPC channel between parent and child, allowing the child to exit
1629
- gracefully once there are no other connections keeping it alive. After calling
1630
- this method the ` subprocess .connected ` and ` process .connected ` properties in
1631
- both the parent and child (respectively) will be set to ` false ` , and it will be
1632
- no longer possible to pass messages between the processes.
1629
+ Closes the IPC channel between parent and child processes, allowing the child
1630
+ process to exit gracefully once there are no other connections keeping it alive.
1631
+ After calling this method the ` subprocess .connected ` and
1632
+ ` process .connected ` properties in both the parent and child processes
1633
+ (respectively) will be set to ` false ` , and it will be no longer possible
1634
+ to pass messages between the processes.
1633
1635
1634
1636
The ` ' disconnect' ` event will be emitted when there are no messages in the
1635
1637
process of being received. This will most often be triggered immediately after
@@ -1805,7 +1807,7 @@ added: v0.7.10
1805
1807
1806
1808
Calling ` subprocess .ref ()` after making a call to ` subprocess .unref ()` will
1807
1809
restore the removed reference count for the child process, forcing the parent
1808
- to wait for the child to exit before exiting itself.
1810
+ process to wait for the child process to exit before exiting itself.
1809
1811
1810
1812
` ` ` cjs
1811
1813
const { spawn } = require (' node:child_process' );
@@ -1862,9 +1864,9 @@ changes:
1862
1864
* ` callback` {Function}
1863
1865
* Returns: {boolean}
1864
1866
1865
- When an IPC channel has been established between the parent and child (
1866
- i.e. when using [` child_process .fork ()` ][]), the ` subprocess .send ()` method can
1867
- be used to send messages to the child process. When the child process is a
1867
+ When an IPC channel has been established between the parent and child processes
1868
+ ( i.e. when using [` child_process .fork ()` ][]), the ` subprocess .send ()` method
1869
+ can be used to send messages to the child process. When the child process is a
1868
1870
Node.js instance, these messages can be received via the [` ' message' ` ][] event.
1869
1871
1870
1872
The message goes through serialization and parsing. The resulting
@@ -1908,7 +1910,7 @@ process.send({ foo: 'bar', baz: NaN });
1908
1910
` ` `
1909
1911
1910
1912
Child Node .js processes will have a [` process.send()` ][] method of their own
1911
- that allows the child to send messages back to the parent.
1913
+ that allows the child process to send messages back to the parent process .
1912
1914
1913
1915
There is a special case when sending a ` {cmd: 'NODE_foo'}` message . Messages
1914
1916
containing a ` NODE_` prefix in the ` cmd` property are reserved for use within
@@ -1919,14 +1921,14 @@ Applications should avoid using such messages or listening for
1919
1921
`' internalMessage' ` events as it is subject to change without notice.
1920
1922
1921
1923
The optional `sendHandle` argument that may be passed to `subprocess.send()` is
1922
- for passing a TCP server or socket object to the child process. The child will
1924
+ for passing a TCP server or socket object to the child process. The child process will
1923
1925
receive the object as the second argument passed to the callback function
1924
1926
registered on the [`' message' `][] event. Any data that is received
1925
1927
and buffered in the socket will not be sent to the child. Sending IPC sockets is
1926
1928
not supported on Windows.
1927
1929
1928
1930
The optional `callback` is a function that is invoked after the message is
1929
- sent but before the child may have received it. The function is called with a
1931
+ sent but before the child process may have received it. The function is called with a
1930
1932
single argument: `null` on success, or an [`Error`][] object on failure.
1931
1933
1932
1934
If no `callback` function is provided and the message cannot be sent, an
@@ -1975,7 +1977,7 @@ server.listen(1337, () => {
1975
1977
});
1976
1978
```
1977
1979
1978
- The child would then receive the server object as:
1980
+ The child process would then receive the server object as:
1979
1981
1980
1982
```js
1981
1983
process.on(' message' , (m, server) => {
@@ -2109,7 +2111,7 @@ added: v0.1.90
2109
2111
2110
2112
A `Readable Stream` that represents the child process' s ` stderr` .
2111
2113
2112
- If the child was spawned with ` stdio[2]` set to anything other than ` 'pipe'` ,
2114
+ If the child process was spawned with ` stdio[2]` set to anything other than ` 'pipe'` ,
2113
2115
then this will be ` null` .
2114
2116
2115
2117
` subprocess.stderr` is an alias for ` subprocess.stdio[2]` . Both properties will
@@ -2128,10 +2130,10 @@ added: v0.1.90
2128
2130
2129
2131
A ` Writable Stream` that represents the child process ' s `stdin`.
2130
2132
2131
- If a child process waits to read all of its input, the child will not continue
2133
+ If a child process waits to read all of its input, the child process will not continue
2132
2134
until this stream has been closed via `end()`.
2133
2135
2134
- If the child was spawned with `stdio[0]` set to anything other than `' pipe' `,
2136
+ If the child process was spawned with `stdio[0]` set to anything other than `' pipe' `,
2135
2137
then this will be `null`.
2136
2138
2137
2139
`subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
@@ -2217,7 +2219,7 @@ added: v0.1.90
2217
2219
2218
2220
A ` Readable Stream` that represents the child process ' s `stdout`.
2219
2221
2220
- If the child was spawned with `stdio[1]` set to anything other than `' pipe' `,
2222
+ If the child process was spawned with `stdio[1]` set to anything other than `' pipe' `,
2221
2223
then this will be `null`.
2222
2224
2223
2225
`subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
@@ -2252,12 +2254,12 @@ if the child process could not be successfully spawned.
2252
2254
added: v0.7.10
2253
2255
-->
2254
2256
2255
- By default, the parent will wait for the detached child to exit. To prevent the
2256
- parent from waiting for a given `subprocess` to exit, use the
2257
+ By default, the parent process will wait for the detached child process to exit.
2258
+ To prevent the parent process from waiting for a given `subprocess` to exit, use the
2257
2259
`subprocess.unref()` method. Doing so will cause the parent' s event loop to not
2258
- include the child in its reference count, allowing the parent to exit
2260
+ include the child process in its reference count, allowing the parent to exit
2259
2261
independently of the child, unless there is an established IPC channel between
2260
- the child and the parent.
2262
+ the child and the parent processes .
2261
2263
2262
2264
` ` ` cjs
2263
2265
const { spawn } = require('node:child_process');
0 commit comments