-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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 ChildProcess 'spawn' event
The new event signals that the subprocess has spawned successfully and no 'error' event will be emitted from failing to spawn. Fixes: #35288 PR-URL: #35369 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 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
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,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const spawn = require('child_process').spawn; | ||
const assert = require('assert'); | ||
|
||
const subprocess = spawn('echo', ['ok']); | ||
|
||
let didSpawn = false; | ||
subprocess.on('spawn', function() { | ||
didSpawn = true; | ||
}); | ||
function mustCallAfterSpawn() { | ||
return common.mustCall(function() { | ||
assert.ok(didSpawn); | ||
}); | ||
} | ||
|
||
subprocess.on('error', common.mustNotCall()); | ||
subprocess.on('spawn', common.mustCall()); | ||
subprocess.stdout.on('data', mustCallAfterSpawn()); | ||
subprocess.stdout.on('end', mustCallAfterSpawn()); | ||
subprocess.stdout.on('close', mustCallAfterSpawn()); | ||
subprocess.stderr.on('data', common.mustNotCall()); | ||
subprocess.stderr.on('end', mustCallAfterSpawn()); | ||
subprocess.stderr.on('close', mustCallAfterSpawn()); | ||
subprocess.on('exit', mustCallAfterSpawn()); | ||
subprocess.on('close', mustCallAfterSpawn()); |