Skip to content

Commit 2e3cb97

Browse files
doc: add API docs for subprocess.timedOut property
Document the timedOut boolean property on ChildProcess that indicates whether the child process was killed due to a timeout option. Refs: #51561
1 parent 0b1f813 commit 2e3cb97

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

doc/api/child_process.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,29 @@ subprocess.stdout.on('data', (data) => {
17851785
The `subprocess.stdout` property can be `null` or `undefined`
17861786
if the child process could not be successfully spawned.
17871787

1788+
### `subprocess.timedOut`
1789+
1790+
<!-- YAML
1791+
added: REPLACEME
1792+
-->
1793+
1794+
* {boolean}
1795+
1796+
The `subprocess.timedOut` property indicates whether the child process
1797+
was killed due to the `timeout` option set in [`child_process.spawn()`][],
1798+
[`child_process.exec()`][], [`child_process.execFile()`][], or
1799+
[`child_process.fork()`][].
1800+
1801+
```js
1802+
const { spawn } = require('node:child_process');
1803+
1804+
const subprocess = spawn('sleep', ['10'], { timeout: 100 });
1805+
1806+
subprocess.on('exit', () => {
1807+
console.log(subprocess.timedOut); // true
1808+
});
1809+
```
1810+
17881811
### `subprocess.unref()`
17891812

17901813
<!-- YAML

0 commit comments

Comments
 (0)