Skip to content

doc: explain child_process code and signal null values everywhere #58479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1448,15 +1448,22 @@ 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
[`'exit'`][] event, since multiple processes might share the same stdio
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']);
Expand Down Expand Up @@ -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
Expand Down
Loading