diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 94663c8085c7a7..051e5c3c0ec37a 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -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