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: nodejs#24647

PR-URL: nodejs#24654
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
  • Loading branch information
addaleax authored and Trott committed Nov 29, 2018
1 parent 9efcfd3 commit 83d6cb9
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 @@ -253,7 +253,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 83d6cb9

Please sign in to comment.