diff --git a/doc/api/child_process.md b/doc/api/child_process.md index e79b411e91eacf..92b36587b38408 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -293,6 +293,8 @@ added: v0.1.90 * `options` {Object} * `cwd` {String} Current working directory of the child process * `env` {Object} Environment key-value pairs + * `argv0` {String} Explicitly set the value of `argv[0]` sent to the child + process. This will be set to `command` if not specified. * `stdio` {Array|String} Child's stdio configuration. (See [`options.stdio`][`stdio`]) * `detached` {Boolean} Prepare child to run independently of its parent @@ -395,6 +397,14 @@ child.on('error', (err) => { }); ``` +*Note: Certain platforms (OS X, Linux) will use the value of `argv[0]` for the +process title while others (Windows, SunOS) will use `command`.* + +*Note: Node.js currently overwrites `argv[0]` with `process.execPath` on +startup, so `process.argv[0]` in a Node.js child process will not match the +`argv0` parameter passed to `spawn` from the parent, retrieve it with the +`process.argv0` property instead.* + #### options.detached + +The `process.argv0` property stores a read-only copy of the original value of +`argv[0]` passed when Node.js starts. + +```js +$ bash -c 'exec -a customArgv0 ./node' +> process.argv[0] +'/Volumes/code/external/node/out/Release/node' +> process.argv0 +'customArgv0' +``` + ## process.chdir(directory)