66
77<!-- source_link=lib/child_process.js -->
88
9- The ` child_process ` module provides the ability to spawn child processes in
9+ The ` child_process ` module provides the ability to spawn subprocesses in
1010a manner that is similar, but not identical, to popen(3). This capability
1111is primarily provided by the [ ` child_process.spawn() ` ] [ ] function:
1212
@@ -28,20 +28,23 @@ ls.on('close', (code) => {
2828```
2929
3030By default, pipes for ` stdin ` , ` stdout ` , and ` stderr ` are established between
31- the parent Node.js process and the spawned child . These pipes have
32- limited (and platform-specific) capacity. If the child process writes to
33- stdout in excess of that limit without the output being captured, the child
34- process will block waiting for the pipe buffer to accept more data. This is
31+ the parent Node.js process and the spawned subprocess . These pipes have
32+ limited (and platform-specific) capacity. If the subprocess writes to
33+ stdout in excess of that limit without the output being captured, the
34+ subprocess blocks waiting for the pipe buffer to accept more data. This is
3535identical to the behavior of pipes in the shell. Use the ` { stdio: 'ignore' } `
3636option if the output will not be consumed.
3737
38- The command lookup will be performed using ` options.env.PATH ` environment
39- variable if passed in ` options ` object, otherwise ` process.env.PATH ` will be
40- used. To account for the fact that Windows environment variables are
41- case-insensitive Node.js will lexicographically sort all ` env ` keys and choose
42- the first one case-insensitively matching ` PATH ` to perform command lookup.
43- This may lead to issues on Windows when passing objects to ` env ` option that
44- have multiple variants of ` PATH ` variable.
38+ The command lookup is performed using the ` options.env.PATH ` environment
39+ variable if it is in the ` options ` object. Otherwise, ` process.env.PATH ` is
40+ used.
41+
42+ On Windows, environment variables are case-insensitive. Node.js
43+ lexicographically sorts the ` env ` keys and uses the first one that
44+ case-insensitively matches. Only first (in lexicographic order) entry will be
45+ passed to the subprocess. This might lead to issues on Windows when passing
46+ objects to the ` env ` option that have multiple variants of the same key, such as
47+ ` PATH ` and ` Path ` .
4548
4649The [ ` child_process.spawn() ` ] [ ] method spawns the child process asynchronously,
4750without blocking the Node.js event loop. The [ ` child_process.spawnSync() ` ] [ ]
0 commit comments