child_process: setup stdio on error when possible · nodejs/node@2bc177a · GitHub
Skip to content

Commit 2bc177a

Browse files
cjihrigBridgeAR
authored andcommitted
child_process: setup stdio on error when possible
As more spawn() errors are classified as runtime errors, it's no longer appropriate to only check UV_ENOENT when determining if stdio can be setup. This commit reverses the check to look for EMFILE and ENFILE specifically. PR-URL: #27696 Fixes: #26852 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 10b4a81 commit 2bc177a

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

lib/internal/child_process.js

Lines changed: 3 additions & 4 deletions

test/parallel/test-child-process-spawn-error.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ const spawnargs = ['bar'];
3030
assert.strictEqual(fs.existsSync(enoentPath), false);
3131

3232
const enoentChild = spawn(enoentPath, spawnargs);
33+
34+
// Verify that stdio is setup if the error is not EMFILE or ENFILE.
35+
assert.notStrictEqual(enoentChild.stdin, undefined);
36+
assert.notStrictEqual(enoentChild.stdout, undefined);
37+
assert.notStrictEqual(enoentChild.stderr, undefined);
38+
assert(Array.isArray(enoentChild.stdio));
39+
assert.strictEqual(enoentChild.stdio[0], enoentChild.stdin);
40+
assert.strictEqual(enoentChild.stdio[1], enoentChild.stdout);
41+
assert.strictEqual(enoentChild.stdio[2], enoentChild.stderr);
42+
3343
enoentChild.on('error', common.mustCall(function(err) {
3444
assert.strictEqual(err.code, 'ENOENT');
3545
assert.strictEqual(err.errno, 'ENOENT');

test/sequential/test-child-process-emfile.js

Lines changed: 6 additions & 0 deletions

0 commit comments

Comments
 (0)