diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2020-11-28 22:42:34 +0300 |
---|---|---|
committer | Benjamin Gruenbaum <benjamingr@gmail.com> | 2020-12-06 13:23:19 +0300 |
commit | 20de5f7efce655d435cfb5ae0811577314fbdeb9 (patch) | |
tree | 427088e55248d84bfc726e3d5f65a1d5ab38689d /doc/api/child_process.md | |
parent | 5477969555727fe75fe72417f9a68634ae9eee3c (diff) |
child_process: add AbortSignal support
PR-URL: https://github.com/nodejs/node/pull/36308
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/child_process.md')
-rw-r--r-- | doc/api/child_process.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 81e843355c9..1972d6c39bb 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -250,6 +250,9 @@ lsExample(); <!-- YAML added: v0.1.91 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/36308 + description: AbortSignal support was added. - version: v8.8.0 pr-url: https://github.com/nodejs/node/pull/15380 description: The `windowsHide` option is supported now. @@ -277,6 +280,7 @@ changes: `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See [Shell requirements][] and [Default Windows shell][]. **Default:** `false` (no shell). + * `signal` {AbortSignal} allows aborting the execFile using an AbortSignal * `callback` {Function} Called with the output when process terminates. * `error` {Error} * `stdout` {string|Buffer} @@ -330,6 +334,19 @@ getVersion(); function. Any input containing shell metacharacters may be used to trigger arbitrary command execution.** +If the `signal` option is enabled, calling `.abort()` on the corresponding +`AbortController` is similar to calling `.kill()` on the child process except +the error passed to the callback will be an `AbortError`: + +```js +const controller = new AbortController(); +const { signal } = controller; +const child = execFile('node', ['--version'], { signal }, (error) => { + console.log(error); // an AbortError +}); +signal.abort(); +``` + ### `child_process.fork(modulePath[, args][, options])` <!-- YAML added: v0.5.0 |