Skip to content

Commit 5a917bc

Browse files
RaisinTenaduh95
authored andcommitted
doc: explain child_process code and signal null values everywhere
Refs: #58463 (comment) Signed-off-by: Darshan Sen <[email protected]> PR-URL: #58479 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 59806b4 commit 5a917bc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

doc/api/child_process.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,15 +1446,22 @@ instances of `ChildProcess`.
14461446
added: v0.7.7
14471447
-->
14481448
1449-
* `code` {number} The exit code if the child process exited on its own.
1450-
* `signal` {string} The signal by which the child process was terminated.
1449+
* `code` {number} The exit code if the child process exited on its own, or
1450+
`null` if the child process terminated due to a signal.
1451+
* `signal` {string} The signal by which the child process was terminated, or
1452+
`null` if the child process did not terminated due to a signal.
14511453
14521454
The `'close'` event is emitted after a process has ended _and_ the stdio
14531455
streams of a child process have been closed. This is distinct from the
14541456
[`'exit'`][] event, since multiple processes might share the same stdio
14551457
streams. The `'close'` event will always emit after [`'exit'`][] was
14561458
already emitted, or [`'error'`][] if the child process failed to spawn.
14571459
1460+
If the process exited, `code` is the final exit code of the process, otherwise
1461+
`null`. If the process terminated due to receipt of a signal, `signal` is the
1462+
string name of the signal, otherwise `null`. One of the two will always be
1463+
non-`null`.
1464+
14581465
```cjs
14591466
const { spawn } = require('node:child_process');
14601467
const ls = spawn('ls', ['-lh', '/usr']);
@@ -1524,8 +1531,10 @@ See also [`subprocess.kill()`][] and [`subprocess.send()`][].
15241531
added: v0.1.90
15251532
-->
15261533
1527-
* `code` {number} The exit code if the child process exited on its own.
1528-
* `signal` {string} The signal by which the child process was terminated.
1534+
* `code` {number} The exit code if the child process exited on its own, or
1535+
`null` if the child process terminated due to a signal.
1536+
* `signal` {string} The signal by which the child process was terminated, or
1537+
`null` if the child process did not terminated due to a signal.
15291538
15301539
The `'exit'` event is emitted after the child process ends. If the process
15311540
exited, `code` is the final exit code of the process, otherwise `null`. If the

0 commit comments

Comments
 (0)