Skip to content

Commit

Permalink
process: fix omitting -- from process.execArgv
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax authored and BethGriggs committed Feb 20, 2019
1 parent dbc01e1 commit 38b0e5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct ArgsInfo {
// on the command line (i.e. not generated through alias expansion).
// '--' is a special case here since its purpose is to end `exec_argv`,
// which is why we do not include it.
if (exec_args != nullptr && first() != "--")
if (exec_args != nullptr && ret != "--")
exec_args->push_back(ret);
underlying->erase(underlying->begin() + 1);
} else {
Expand Down
23 changes: 13 additions & 10 deletions test/parallel/test-process-exec-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
process.stdout.write(JSON.stringify(process.execArgv));
} else {
const execArgv = ['--stack-size=256'];
const args = [__filename, 'child', 'arg0'];
const child = spawn(process.execPath, execArgv.concat(args));
let out = '';
for (const extra of [ [], [ '--' ] ]) {
const execArgv = ['--stack-size=256'];
const args = [__filename, 'child', 'arg0'];
const child = spawn(process.execPath, [...execArgv, ...extra, ...args]);
let out = '';

child.stdout.on('data', function(chunk) {
out += chunk;
});
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
out += chunk;
});

child.on('close', function() {
assert.deepStrictEqual(JSON.parse(out), execArgv);
});
child.on('close', function() {
assert.deepStrictEqual(JSON.parse(out), execArgv);
});
}
}

0 comments on commit 38b0e5d

Please sign in to comment.