mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
doc: explain child_process code and signal null values everywhere
Refs: https://github.com/nodejs/node/issues/58463#issuecomment-2911460454 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/58479 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
fd46569a50
commit
a984ed388a
1 file changed
+13
-4
@@ -1448,8 +1448,10 @@ instances of `ChildProcess`.
|
||||
added: v0.7.7
|
||||
-->
|
||||
|
||||
* `code` {number} The exit code if the child process exited on its own.
|
||||
* `signal` {string} The signal by which the child process was terminated.
|
||||
* `code` {number} The exit code if the child process exited on its own, or
|
||||
`null` if the child process terminated due to a signal.
|
||||
* `signal` {string} The signal by which the child process was terminated, or
|
||||
`null` if the child process did not terminated due to a signal.
|
||||
|
||||
The `'close'` event is emitted after a process has ended _and_ the stdio
|
||||
streams of a child process have been closed. This is distinct from the
|
||||
@@ -1457,6 +1459,11 @@ streams of a child process have been closed. This is distinct from the
|
||||
streams. The `'close'` event will always emit after [`'exit'`][] was
|
||||
already emitted, or [`'error'`][] if the child process failed to spawn.
|
||||
|
||||
If the process exited, `code` is the final exit code of the process, otherwise
|
||||
`null`. If the process terminated due to receipt of a signal, `signal` is the
|
||||
string name of the signal, otherwise `null`. One of the two will always be
|
||||
non-`null`.
|
||||
|
||||
```cjs
|
||||
const { spawn } = require('node:child_process');
|
||||
const ls = spawn('ls', ['-lh', '/usr']);
|
||||
@@ -1526,8 +1533,10 @@ See also [`subprocess.kill()`][] and [`subprocess.send()`][].
|
||||
added: v0.1.90
|
||||
-->
|
||||
|
||||
* `code` {number} The exit code if the child process exited on its own.
|
||||
* `signal` {string} The signal by which the child process was terminated.
|
||||
* `code` {number} The exit code if the child process exited on its own, or
|
||||
`null` if the child process terminated due to a signal.
|
||||
* `signal` {string} The signal by which the child process was terminated, or
|
||||
`null` if the child process did not terminated due to a signal.
|
||||
|
||||
The `'exit'` event is emitted after the child process ends. If the process
|
||||
exited, `code` is the final exit code of the process, otherwise `null`. If the
|
||||
|
||||
Reference in new issue
Block a user