Skip to content

Commit 931a04e

Browse files
addaleaxBethGriggs
authored andcommitted
process: fix omitting -- from process.execArgv
This was essentially a typo that went unnoticed because we didn’t have tests for this particular situation. Fixes: #24647 PR-URL: #24654 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent cfd5773 commit 931a04e

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/node_options-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ struct ArgsInfo {
266266
// on the command line (i.e. not generated through alias expansion).
267267
// '--' is a special case here since its purpose is to end `exec_argv`,
268268
// which is why we do not include it.
269-
if (exec_args != nullptr && first() != "--")
269+
if (exec_args != nullptr && ret != "--")
270270
exec_args->push_back(ret);
271271
underlying->erase(underlying->begin() + 1);
272272
} else {

test/parallel/test-process-exec-argv.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ const spawn = require('child_process').spawn;
2727
if (process.argv[2] === 'child') {
2828
process.stdout.write(JSON.stringify(process.execArgv));
2929
} else {
30-
const execArgv = ['--stack-size=256'];
31-
const args = [__filename, 'child', 'arg0'];
32-
const child = spawn(process.execPath, execArgv.concat(args));
33-
let out = '';
30+
for (const extra of [ [], [ '--' ] ]) {
31+
const execArgv = ['--stack-size=256'];
32+
const args = [__filename, 'child', 'arg0'];
33+
const child = spawn(process.execPath, [...execArgv, ...extra, ...args]);
34+
let out = '';
3435

35-
child.stdout.on('data', function(chunk) {
36-
out += chunk;
37-
});
36+
child.stdout.setEncoding('utf8');
37+
child.stdout.on('data', function(chunk) {
38+
out += chunk;
39+
});
3840

39-
child.on('close', function() {
40-
assert.deepStrictEqual(JSON.parse(out), execArgv);
41-
});
41+
child.on('close', function() {
42+
assert.deepStrictEqual(JSON.parse(out), execArgv);
43+
});
44+
}
4245
}

0 commit comments

Comments
 (0)