-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
child_process: add signal support to spawn
PR-URL: #36432 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
1 parent
d50b2ff
commit 738cd60
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
|
||
// Verify that passing an AbortSignal works | ||
const controller = new AbortController(); | ||
const { signal } = controller; | ||
|
||
const echo = cp.spawn('echo', ['fun'], { | ||
encoding: 'utf8', | ||
shell: true, | ||
signal | ||
}); | ||
|
||
echo.on('error', common.mustCall((e) => { | ||
assert.strictEqual(e.name, 'AbortError'); | ||
})); | ||
|
||
controller.abort(); |