Skip to content

Commit 60e112d

Browse files
committed
child_process: support execArgv in spawn()
The execArgv option passed to spawn() was being silently ignored. This commit adds proper handling of execArgv in normalizeSpawnArguments(), prepending the execArgv values to the args array before argv0/file. Fixes: #65725 PR-URL: #65726
1 parent 09f5aae commit 60e112d

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

doc/api/child_process.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ changes:
695695
* `env` {Object} Environment key-value pairs. **Default:** `process.env`.
696696
* `argv0` {string} Explicitly set the value of `argv[0]` sent to the child
697697
process. This will be set to `command` if not specified.
698+
* `execArgv` {string\[]} List of string arguments passed to the executable.
698699
* `stdio` {Array|string} Child's stdio configuration (see
699700
[`options.stdio`][`stdio`]).
700701
* `detached` {boolean} Prepare child process to run independently of

lib/child_process.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,13 @@ function normalizeSpawnArguments(file, args, options) {
691691
}
692692
}
693693

694+
// Handle execArgv - prepend to args if provided
695+
if (options.execArgv != null) {
696+
validateArray(options.execArgv, 'options.execArgv');
697+
validateArgumentsNullCheck(options.execArgv, 'options.execArgv');
698+
args = [...options.execArgv, ...args];
699+
}
700+
694701
if (typeof options.argv0 === 'string') {
695702
ArrayPrototypeUnshift(args, options.argv0);
696703
} else {
@@ -788,6 +795,7 @@ function abortChildProcess(child, killSignal, reason) {
788795
* cwd?: string | URL;
789796
* env?: Record<string, string>;
790797
* argv0?: string;
798+
* execArgv?: string[];
791799
* stdio?: Array | string;
792800
* detached?: boolean;
793801
* uid?: number;

0 commit comments

Comments
 (0)