-
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: handle undefined/null for fork() args
PR-URL: #22416 Fixes: #20749 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Matheus Marchini <[email protected]>
- Loading branch information
1 parent
5bedd1c
commit df5a19f
Showing
3 changed files
with
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
process.send({ env: process.env }); |
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,37 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// This test ensures that fork should parse options | ||
// correctly if args is undefined or null | ||
|
||
const assert = require('assert'); | ||
const { fork } = require('child_process'); | ||
|
||
const expectedEnv = { foo: 'bar' }; | ||
|
||
{ | ||
const cp = fork(fixtures.path('child-process-echo-options.js'), undefined, | ||
{ env: Object.assign({}, process.env, expectedEnv) }); | ||
|
||
cp.on('message', common.mustCall(({ env }) => { | ||
assert.strictEqual(env.foo, expectedEnv.foo); | ||
})); | ||
|
||
cp.on('exit', common.mustCall((code) => { | ||
assert.strictEqual(code, 0); | ||
})); | ||
} | ||
|
||
{ | ||
const cp = fork(fixtures.path('child-process-echo-options.js'), null, | ||
{ env: Object.assign({}, process.env, expectedEnv) }); | ||
|
||
cp.on('message', common.mustCall(({ env }) => { | ||
assert.strictEqual(env.foo, expectedEnv.foo); | ||
})); | ||
|
||
cp.on('exit', common.mustCall((code) => { | ||
assert.strictEqual(code, 0); | ||
})); | ||
} |