{
  "type": "module",
  "source": "doc/api/child_process.md",
  "modules": [
    {
      "textRaw": "Child process",
      "name": "child_process",
      "introduced_in": "v0.10.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>The <code>node:child_process</code> module provides the ability to spawn subprocesses in\na manner that is similar, but not identical, to <a href=\"http://man7.org/linux/man-pages/man3/popen.3.html\"><code>popen(3)</code></a>. This capability\nis primarily provided by the <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> function:</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst ls = spawn('ls', ['-lh', '/usr']);\n\nls.stdout.on('data', (data) => {\n  console.log(`stdout: ${data}`);\n});\n\nls.stderr.on('data', (data) => {\n  console.error(`stderr: ${data}`);\n});\n\nls.on('close', (code) => {\n  console.log(`child process exited with code ${code}`);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport { once } from 'node:events';\nconst ls = spawn('ls', ['-lh', '/usr']);\n\nls.stdout.on('data', (data) => {\n  console.log(`stdout: ${data}`);\n});\n\nls.stderr.on('data', (data) => {\n  console.error(`stderr: ${data}`);\n});\n\nconst [code] = await once(ls, 'close');\nconsole.log(`child process exited with code ${code}`);\n</code></pre>\n<p>By default, pipes for <code>stdin</code>, <code>stdout</code>, and <code>stderr</code> are established between\nthe parent Node.js process and the spawned subprocess. These pipes have\nlimited (and platform-specific) capacity. If the subprocess writes to\nstdout in excess of that limit without the output being captured, the\nsubprocess blocks, waiting for the pipe buffer to accept more data. This is\nidentical to the behavior of pipes in the shell. Use the <code>{ stdio: 'ignore' }</code>\noption if the output will not be consumed.</p>\n<p>The command lookup is performed using the <code>options.env.PATH</code> environment\nvariable if <code>env</code> is in the <code>options</code> object. Otherwise, <code>process.env.PATH</code> is\nused. If <code>options.env</code> is set without <code>PATH</code>, lookup on Unix is performed\non a default search path search of <code>/usr/bin:/bin</code> (see your operating system's\nmanual for execvpe/execvp), on Windows the current processes environment\nvariable <code>PATH</code> is used.</p>\n<p>On Windows, environment variables are case-insensitive. Node.js\nlexicographically sorts the <code>env</code> keys and uses the first one that\ncase-insensitively matches. Only first (in lexicographic order) entry will be\npassed to the subprocess. This might lead to issues on Windows when passing\nobjects to the <code>env</code> option that have multiple variants of the same key, such as\n<code>PATH</code> and <code>Path</code>.</p>\n<p>The <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> method spawns the child process asynchronously,\nwithout blocking the Node.js event loop. The <a href=\"#child_processspawnsynccommand-args-options\"><code>child_process.spawnSync()</code></a>\nfunction provides equivalent functionality in a synchronous manner that blocks\nthe event loop until the spawned process either exits or is terminated.</p>\n<p>For convenience, the <code>node:child_process</code> module provides a handful of\nsynchronous and asynchronous alternatives to <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> and\n<a href=\"#child_processspawnsynccommand-args-options\"><code>child_process.spawnSync()</code></a>. Each of these alternatives are implemented on\ntop of <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> or <a href=\"#child_processspawnsynccommand-args-options\"><code>child_process.spawnSync()</code></a>.</p>\n<ul>\n<li><a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>: spawns a shell and runs a command within that\nshell, passing the <code>stdout</code> and <code>stderr</code> to a callback function when\ncomplete.</li>\n<li><a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a>: similar to <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> except\nthat it spawns the command directly without first spawning a shell by\ndefault.</li>\n<li><a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>: spawns a new Node.js process and invokes a\nspecified module with an IPC communication channel established that allows\nsending messages between parent and child.</li>\n<li><a href=\"#child_processexecsynccommand-options\"><code>child_process.execSync()</code></a>: a synchronous version of\n<a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> that will block the Node.js event loop.</li>\n<li><a href=\"#child_processexecfilesyncfile-args-options\"><code>child_process.execFileSync()</code></a>: a synchronous version of\n<a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a> that will block the Node.js event loop.</li>\n</ul>\n<p>For certain use cases, such as automating shell scripts, the\n<a href=\"#synchronous-process-creation\">synchronous counterparts</a> may be more convenient. In many cases, however,\nthe synchronous methods can have significant impact on performance due to\nstalling the event loop while spawned processes complete.</p>",
      "modules": [
        {
          "textRaw": "Asynchronous process creation",
          "name": "asynchronous_process_creation",
          "type": "module",
          "desc": "<p>The <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a>, <a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>, <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>,\nand <a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a> methods all follow the idiomatic asynchronous\nprogramming pattern typical of other Node.js APIs.</p>\n<p>Each of the methods returns a <a href=\"#class-childprocess\"><code>ChildProcess</code></a> instance. These objects\nimplement the Node.js <a href=\"events.html#class-eventemitter\"><code>EventEmitter</code></a> API, allowing the parent process to\nregister listener functions that are called when certain events occur during\nthe life cycle of the child process.</p>\n<p>The <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> and <a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a> methods\nadditionally allow for an optional <code>callback</code> function to be specified that is\ninvoked when the child process terminates.</p>",
          "modules": [
            {
              "textRaw": "Spawning `.bat` and `.cmd` files on Windows",
              "name": "spawning_`.bat`_and_`.cmd`_files_on_windows",
              "type": "module",
              "desc": "<p>The importance of the distinction between <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> and\n<a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a> can vary based on platform. On Unix-type\noperating systems (Unix, Linux, macOS) <a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a> can be\nmore efficient because it does not spawn a shell by default. On Windows,\nhowever, <code>.bat</code> and <code>.cmd</code> files are not executable on their own without a\nterminal, and therefore cannot be launched using <a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a>.\nWhen running on Windows, <code>.bat</code> and <code>.cmd</code> files can be invoked by:</p>\n<ul>\n<li>using <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> with the <code>shell</code> option set (not recommended, see <a href=\"deprecations.html#DEP0190\">DEP0190</a>), or</li>\n<li>using <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>, or</li>\n<li>spawning <code>cmd.exe</code> and passing the <code>.bat</code> or <code>.cmd</code> file as an argument\n(which is what <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> does internally).</li>\n</ul>\n<p>In any case, if the script filename contains spaces, it needs to be quoted.</p>\n<pre><code class=\"language-cjs\">const { exec, spawn } = require('node:child_process');\n\nexec('my.bat', (err, stdout, stderr) => { /* ... */ });\n\n// Or, spawning cmd.exe directly:\nconst bat = spawn('cmd.exe', ['/c', 'my.bat']);\n\n// If the script filename contains spaces, it needs to be quoted\nexec('\"my script.cmd\" a b', (err, stdout, stderr) => { /* ... */ });\n</code></pre>\n<pre><code class=\"language-mjs\">import { exec, spawn } from 'node:child_process';\n\nexec('my.bat', (err, stdout, stderr) => { /* ... */ });\n\n// Or, spawning cmd.exe directly:\nconst bat = spawn('cmd.exe', ['/c', 'my.bat']);\n\n// If the script filename contains spaces, it needs to be quoted\nexec('\"my script.cmd\" a b', (err, stdout, stderr) => { /* ... */ });\n</code></pre>",
              "displayName": "Spawning `.bat` and `.cmd` files on Windows"
            }
          ],
          "methods": [
            {
              "textRaw": "`child_process.exec(command[, options][, callback])`",
              "name": "exec",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": [
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": "v15.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/36308",
                    "description": "AbortSignal support was added."
                  },
                  {
                    "version": "v8.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/15380",
                    "description": "The `windowsHide` option is supported now."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`command` {string} The command to run, with space-separated arguments.",
                      "name": "command",
                      "type": "string",
                      "desc": "The command to run, with space-separated arguments."
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process. **Default:** `process.cwd()`.",
                          "name": "cwd",
                          "type": "string|URL",
                          "default": "`process.cwd()`",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`encoding` {string} **Default:** `'utf8'`",
                          "name": "encoding",
                          "type": "string",
                          "default": "`'utf8'`"
                        },
                        {
                          "textRaw": "`shell` {string} Shell to execute the command with. See Shell requirements and Default Windows shell. **Default:** `'/bin/sh'` on Unix, `process.env.ComSpec` on Windows.",
                          "name": "shell",
                          "type": "string",
                          "default": "`'/bin/sh'` on Unix, `process.env.ComSpec` on Windows",
                          "desc": "Shell to execute the command with. See Shell requirements and Default Windows shell."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} allows aborting the child process using an AbortSignal.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "allows aborting the child process using an AbortSignal."
                        },
                        {
                          "textRaw": "`timeout` {number} **Default:** `0`",
                          "name": "timeout",
                          "type": "number",
                          "default": "`0`"
                        },
                        {
                          "textRaw": "`maxBuffer` {number} Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode. **Default:** `1024 * 1024`.",
                          "name": "maxBuffer",
                          "type": "number",
                          "default": "`1024 * 1024`",
                          "desc": "Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} **Default:** `'SIGTERM'`",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`"
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process (see `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process (see `setuid(2)`)."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process (see `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process (see `setgid(2)`)."
                        },
                        {
                          "textRaw": "`windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`.",
                          "name": "windowsHide",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Hide the subprocess console window that would normally be created on Windows systems."
                        }
                      ],
                      "optional": true
                    },
                    {
                      "textRaw": "`callback` {Function} called with the output when process terminates.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "called with the output when process terminates.",
                      "options": [
                        {
                          "textRaw": "`error` {Error}",
                          "name": "error",
                          "type": "Error"
                        },
                        {
                          "textRaw": "`stdout` {string|Buffer}",
                          "name": "stdout",
                          "type": "string|Buffer"
                        },
                        {
                          "textRaw": "`stderr` {string|Buffer}",
                          "name": "stderr",
                          "type": "string|Buffer"
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {ChildProcess}",
                    "name": "return",
                    "type": "ChildProcess"
                  }
                }
              ],
              "desc": "<p>Spawns a shell then executes the <code>command</code> within that shell, buffering any\ngenerated output. The <code>command</code> string passed to the exec function is processed\ndirectly by the shell and special characters (vary based on\n<a href=\"https://en.wikipedia.org/wiki/List_of_command-line_interpreters\">shell</a>)\nneed to be dealt with accordingly:</p>\n<pre><code class=\"language-cjs\">const { exec } = require('node:child_process');\n\nexec('\"/path/to/test file/test.sh\" arg1 arg2');\n// Double quotes are used so that the space in the path is not interpreted as\n// a delimiter of multiple arguments.\n\nexec('echo \"The \\\\$HOME variable is $HOME\"');\n// The $HOME variable is escaped in the first instance, but not in the second.\n</code></pre>\n<pre><code class=\"language-mjs\">import { exec } from 'node:child_process';\n\nexec('\"/path/to/test file/test.sh\" arg1 arg2');\n// Double quotes are used so that the space in the path is not interpreted as\n// a delimiter of multiple arguments.\n\nexec('echo \"The \\\\$HOME variable is $HOME\"');\n// The $HOME variable is escaped in the first instance, but not in the second.\n</code></pre>\n<p><strong>Never pass unsanitized user input to this function. Any input containing shell\nmetacharacters may be used to trigger arbitrary command execution.</strong></p>\n<p>If a <code>callback</code> function is provided, it is called with the arguments\n<code>(error, stdout, stderr)</code>. On success, <code>error</code> will be <code>null</code>. On error,\n<code>error</code> will be an instance of <a href=\"errors.html#class-error\"><code>Error</code></a>. The <code>error.code</code> property will be\nthe exit code of the process. By convention, any exit code other than <code>0</code>\nindicates an error. <code>error.signal</code> will be the signal that terminated the\nprocess.</p>\n<p>The <code>stdout</code> and <code>stderr</code> arguments passed to the callback will contain the\nstdout and stderr output of the child process. By default, Node.js will decode\nthe output as UTF-8 and pass strings to the callback. The <code>encoding</code> option\ncan be used to specify the character encoding used to decode the stdout and\nstderr output. If <code>encoding</code> is <code>'buffer'</code>, or an unrecognized character\nencoding, <code>Buffer</code> objects will be passed to the callback instead.</p>\n<pre><code class=\"language-cjs\">const { exec } = require('node:child_process');\nexec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {\n  if (error) {\n    console.error(`exec error: ${error}`);\n    return;\n  }\n  console.log(`stdout: ${stdout}`);\n  console.error(`stderr: ${stderr}`);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { exec } from 'node:child_process';\nexec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {\n  if (error) {\n    console.error(`exec error: ${error}`);\n    return;\n  }\n  console.log(`stdout: ${stdout}`);\n  console.error(`stderr: ${stderr}`);\n});\n</code></pre>\n<p>If <code>timeout</code> is greater than <code>0</code>, the parent process will send the signal\nidentified by the <code>killSignal</code> property (the default is <code>'SIGTERM'</code>) if the\nchild process runs longer than <code>timeout</code> milliseconds.</p>\n<p>Unlike the <a href=\"http://man7.org/linux/man-pages/man3/exec.3.html\"><code>exec(3)</code></a> POSIX system call, <code>child_process.exec()</code> does not replace\nthe existing process and uses a shell to execute the command.</p>\n<p>If this method is invoked as its <a href=\"util.html#utilpromisifyoriginal\"><code>util.promisify()</code></a>ed version, it returns\na <code>Promise</code> for an <code>Object</code> with <code>stdout</code> and <code>stderr</code> properties. The returned\n<code>ChildProcess</code> instance is attached to the <code>Promise</code> as a <code>child</code> property. In\ncase of an error (including any error resulting in an exit code other than 0), a\nrejected promise is returned, with the same <code>error</code> object given in the\ncallback, but with two additional properties <code>stdout</code> and <code>stderr</code>.</p>\n<pre><code class=\"language-cjs\">const util = require('node:util');\nconst exec = util.promisify(require('node:child_process').exec);\n\nasync function lsExample() {\n  const { stdout, stderr } = await exec('ls');\n  console.log('stdout:', stdout);\n  console.error('stderr:', stderr);\n}\nlsExample();\n</code></pre>\n<pre><code class=\"language-mjs\">import { promisify } from 'node:util';\nimport child_process from 'node:child_process';\nconst exec = promisify(child_process.exec);\n\nasync function lsExample() {\n  const { stdout, stderr } = await exec('ls');\n  console.log('stdout:', stdout);\n  console.error('stderr:', stderr);\n}\nlsExample();\n</code></pre>\n<p>If the <code>signal</code> option is enabled, calling <code>.abort()</code> on the corresponding\n<code>AbortController</code> is similar to calling <code>.kill()</code> on the child process except\nthe error passed to the callback will be an <code>AbortError</code>:</p>\n<pre><code class=\"language-cjs\">const { exec } = require('node:child_process');\nconst controller = new AbortController();\nconst { signal } = controller;\nconst child = exec('grep ssh', { signal }, (error) => {\n  console.error(error); // an AbortError\n});\ncontroller.abort();\n</code></pre>\n<pre><code class=\"language-mjs\">import { exec } from 'node:child_process';\nconst controller = new AbortController();\nconst { signal } = controller;\nconst child = exec('grep ssh', { signal }, (error) => {\n  console.error(error); // an AbortError\n});\ncontroller.abort();\n</code></pre>"
            },
            {
              "textRaw": "`child_process.execFile(file[, args][, options][, callback])`",
              "name": "execFile",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.91"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.11.0",
                      "v22.15.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57389",
                    "description": "Passing `args` when `shell` is set to `true` is deprecated."
                  },
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": [
                      "v15.4.0",
                      "v14.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/36308",
                    "description": "AbortSignal support was added."
                  },
                  {
                    "version": "v8.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/15380",
                    "description": "The `windowsHide` option is supported now."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`file` {string} The name or path of the executable file to run.",
                      "name": "file",
                      "type": "string",
                      "desc": "The name or path of the executable file to run."
                    },
                    {
                      "textRaw": "`args` {string}[] List of string arguments.",
                      "name": "args",
                      "type": "string",
                      "desc": "[] List of string arguments.",
                      "optional": true
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process.",
                          "name": "cwd",
                          "type": "string|URL",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`encoding` {string} **Default:** `'utf8'`",
                          "name": "encoding",
                          "type": "string",
                          "default": "`'utf8'`"
                        },
                        {
                          "textRaw": "`timeout` {number} **Default:** `0`",
                          "name": "timeout",
                          "type": "number",
                          "default": "`0`"
                        },
                        {
                          "textRaw": "`maxBuffer` {number} Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode. **Default:** `1024 * 1024`.",
                          "name": "maxBuffer",
                          "type": "number",
                          "default": "`1024 * 1024`",
                          "desc": "Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} **Default:** `'SIGTERM'`",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`"
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process (see `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process (see `setuid(2)`)."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process (see `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process (see `setgid(2)`)."
                        },
                        {
                          "textRaw": "`windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`.",
                          "name": "windowsHide",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Hide the subprocess console window that would normally be created on Windows systems."
                        },
                        {
                          "textRaw": "`windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is done on Windows. Ignored on Unix. **Default:** `false`.",
                          "name": "windowsVerbatimArguments",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "No quoting or escaping of arguments is done on Windows. Ignored on Unix."
                        },
                        {
                          "textRaw": "`shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell. **Default:** `false` (no shell).",
                          "name": "shell",
                          "type": "boolean|string",
                          "default": "`false` (no shell)",
                          "desc": "If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} allows aborting the child process using an AbortSignal.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "allows aborting the child process using an AbortSignal."
                        }
                      ],
                      "optional": true
                    },
                    {
                      "textRaw": "`callback` {Function} Called with the output when process terminates.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Called with the output when process terminates.",
                      "options": [
                        {
                          "textRaw": "`error` {Error}",
                          "name": "error",
                          "type": "Error"
                        },
                        {
                          "textRaw": "`stdout` {string|Buffer}",
                          "name": "stdout",
                          "type": "string|Buffer"
                        },
                        {
                          "textRaw": "`stderr` {string|Buffer}",
                          "name": "stderr",
                          "type": "string|Buffer"
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {ChildProcess}",
                    "name": "return",
                    "type": "ChildProcess"
                  }
                }
              ],
              "desc": "<p>The <code>child_process.execFile()</code> function is similar to <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>\nexcept that it does not spawn a shell by default. Rather, the specified\nexecutable <code>file</code> is spawned directly as a new process making it slightly more\nefficient than <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>.</p>\n<p>The same options as <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> are supported. Since a shell is\nnot spawned, behaviors such as I/O redirection and file globbing are not\nsupported.</p>\n<pre><code class=\"language-cjs\">const { execFile } = require('node:child_process');\nconst child = execFile('node', ['--version'], (error, stdout, stderr) => {\n  if (error) {\n    throw error;\n  }\n  console.log(stdout);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { execFile } from 'node:child_process';\nconst child = execFile('node', ['--version'], (error, stdout, stderr) => {\n  if (error) {\n    throw error;\n  }\n  console.log(stdout);\n});\n</code></pre>\n<p>The <code>stdout</code> and <code>stderr</code> arguments passed to the callback will contain the\nstdout and stderr output of the child process. By default, Node.js will decode\nthe output as UTF-8 and pass strings to the callback. The <code>encoding</code> option\ncan be used to specify the character encoding used to decode the stdout and\nstderr output. If <code>encoding</code> is <code>'buffer'</code>, or an unrecognized character\nencoding, <code>Buffer</code> objects will be passed to the callback instead.</p>\n<p>If this method is invoked as its <a href=\"util.html#utilpromisifyoriginal\"><code>util.promisify()</code></a>ed version, it returns\na <code>Promise</code> for an <code>Object</code> with <code>stdout</code> and <code>stderr</code> properties. The returned\n<code>ChildProcess</code> instance is attached to the <code>Promise</code> as a <code>child</code> property. In\ncase of an error (including any error resulting in an exit code other than 0), a\nrejected promise is returned, with the same <code>error</code> object given in the\ncallback, but with two additional properties <code>stdout</code> and <code>stderr</code>.</p>\n<pre><code class=\"language-cjs\">const util = require('node:util');\nconst execFile = util.promisify(require('node:child_process').execFile);\nasync function getVersion() {\n  const { stdout } = await execFile('node', ['--version']);\n  console.log(stdout);\n}\ngetVersion();\n</code></pre>\n<pre><code class=\"language-mjs\">import { promisify } from 'node:util';\nimport child_process from 'node:child_process';\nconst execFile = promisify(child_process.execFile);\nasync function getVersion() {\n  const { stdout } = await execFile('node', ['--version']);\n  console.log(stdout);\n}\ngetVersion();\n</code></pre>\n<p><strong>If the <code>shell</code> option is enabled, do not pass unsanitized user input to this\nfunction. Any input containing shell metacharacters may be used to trigger\narbitrary command execution.</strong></p>\n<p>If the <code>signal</code> option is enabled, calling <code>.abort()</code> on the corresponding\n<code>AbortController</code> is similar to calling <code>.kill()</code> on the child process except\nthe error passed to the callback will be an <code>AbortError</code>:</p>\n<pre><code class=\"language-cjs\">const { execFile } = require('node:child_process');\nconst controller = new AbortController();\nconst { signal } = controller;\nconst child = execFile('node', ['--version'], { signal }, (error) => {\n  console.error(error); // an AbortError\n});\ncontroller.abort();\n</code></pre>\n<pre><code class=\"language-mjs\">import { execFile } from 'node:child_process';\nconst controller = new AbortController();\nconst { signal } = controller;\nconst child = execFile('node', ['--version'], { signal }, (error) => {\n  console.error(error); // an AbortError\n});\ncontroller.abort();\n</code></pre>"
            },
            {
              "textRaw": "`child_process.fork(modulePath[, args][, options])`",
              "name": "fork",
              "type": "method",
              "meta": {
                "added": [
                  "v0.5.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v17.4.0",
                      "v16.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/41225",
                    "description": "The `modulePath` parameter can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": [
                      "v15.13.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/37256",
                    "description": "timeout was added."
                  },
                  {
                    "version": [
                      "v15.11.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/37325",
                    "description": "killSignal for AbortSignal was added."
                  },
                  {
                    "version": [
                      "v15.6.0",
                      "v14.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/36603",
                    "description": "AbortSignal support was added."
                  },
                  {
                    "version": [
                      "v13.2.0",
                      "v12.16.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/30162",
                    "description": "The `serialization` option is supported now."
                  },
                  {
                    "version": "v8.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/10866",
                    "description": "The `stdio` option can now be a string."
                  },
                  {
                    "version": "v6.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/7811",
                    "description": "The `stdio` option is supported now."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`modulePath` {string|URL} The module to run in the child.",
                      "name": "modulePath",
                      "type": "string|URL",
                      "desc": "The module to run in the child."
                    },
                    {
                      "textRaw": "`args` {string}[] List of string arguments.",
                      "name": "args",
                      "type": "string",
                      "desc": "[] List of string arguments.",
                      "optional": true
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process.",
                          "name": "cwd",
                          "type": "string|URL",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`detached` {boolean} Prepare child process to run independently of its parent process. Specific behavior depends on the platform (see `options.detached`).",
                          "name": "detached",
                          "type": "boolean",
                          "desc": "Prepare child process to run independently of its parent process. Specific behavior depends on the platform (see `options.detached`)."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`execPath` {string} Executable used to create the child process.",
                          "name": "execPath",
                          "type": "string",
                          "desc": "Executable used to create the child process."
                        },
                        {
                          "textRaw": "`execArgv` {string}[] List of string arguments passed to the executable. **Default:** `process.execArgv`.",
                          "name": "execArgv",
                          "type": "string",
                          "default": "`process.execArgv`",
                          "desc": "[] List of string arguments passed to the executable."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process (see `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process (see `setgid(2)`)."
                        },
                        {
                          "textRaw": "`serialization` {string} Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. See Advanced serialization for more details. **Default:** `'json'`.",
                          "name": "serialization",
                          "type": "string",
                          "default": "`'json'`",
                          "desc": "Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. See Advanced serialization for more details."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} Allows closing the child process using an AbortSignal.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "Allows closing the child process using an AbortSignal."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} The signal value to be used when the spawned process will be killed by timeout or abort signal. **Default:** `'SIGTERM'`.",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`",
                          "desc": "The signal value to be used when the spawned process will be killed by timeout or abort signal."
                        },
                        {
                          "textRaw": "`silent` {boolean} If `true`, stdin, stdout, and stderr of the child process will be piped to the parent process, otherwise they will be inherited from the parent process, see the `'pipe'` and `'inherit'` options for `child_process.spawn()`'s `stdio` for more details. **Default:** `false`.",
                          "name": "silent",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If `true`, stdin, stdout, and stderr of the child process will be piped to the parent process, otherwise they will be inherited from the parent process, see the `'pipe'` and `'inherit'` options for `child_process.spawn()`'s `stdio` for more details."
                        },
                        {
                          "textRaw": "`stdio` {Array|string} See `child_process.spawn()`'s `stdio`. When this option is provided, it overrides `silent`. If the array variant is used, it must contain exactly one item with value `'ipc'` or an error will be thrown. For instance `[0, 1, 2, 'ipc']`.",
                          "name": "stdio",
                          "type": "Array|string",
                          "desc": "See `child_process.spawn()`'s `stdio`. When this option is provided, it overrides `silent`. If the array variant is used, it must contain exactly one item with value `'ipc'` or an error will be thrown. For instance `[0, 1, 2, 'ipc']`."
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process (see `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process (see `setuid(2)`)."
                        },
                        {
                          "textRaw": "`windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is done on Windows. Ignored on Unix. **Default:** `false`.",
                          "name": "windowsVerbatimArguments",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "No quoting or escaping of arguments is done on Windows. Ignored on Unix."
                        },
                        {
                          "textRaw": "`timeout` {number} In milliseconds the maximum amount of time the process is allowed to run. **Default:** `undefined`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`undefined`",
                          "desc": "In milliseconds the maximum amount of time the process is allowed to run."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {ChildProcess}",
                    "name": "return",
                    "type": "ChildProcess"
                  }
                }
              ],
              "desc": "<p>The <code>child_process.fork()</code> method is a special case of\n<a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> used specifically to spawn new Node.js processes.\nLike <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a>, a <a href=\"#class-childprocess\"><code>ChildProcess</code></a> object is returned. The\nreturned <a href=\"#class-childprocess\"><code>ChildProcess</code></a> will have an additional communication channel\nbuilt-in that allows messages to be passed back and forth between the parent and\nchild. See <a href=\"#subprocesssendmessage-sendhandle-options-callback\"><code>subprocess.send()</code></a> for details.</p>\n<p>Keep in mind that spawned Node.js child processes are\nindependent of the parent with exception of the IPC communication channel\nthat is established between the two. Each process has its own memory, with\ntheir own V8 instances. Because of the additional resource allocations\nrequired, spawning a large number of child Node.js processes is not\nrecommended.</p>\n<p>By default, <code>child_process.fork()</code> will spawn new Node.js instances using the\n<a href=\"process.html#processexecpath\"><code>process.execPath</code></a> of the parent process. The <code>execPath</code> property in the\n<code>options</code> object allows for an alternative execution path to be used.</p>\n<p>Node.js processes launched with a custom <code>execPath</code> will communicate with the\nparent process using the file descriptor (fd) identified using the\nenvironment variable <code>NODE_CHANNEL_FD</code> on the child process.</p>\n<p>Unlike the <a href=\"http://man7.org/linux/man-pages/man2/fork.2.html\"><code>fork(2)</code></a> POSIX system call, <code>child_process.fork()</code> does not clone the\ncurrent process.</p>\n<p>The <code>shell</code> option available in <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> is not supported by\n<code>child_process.fork()</code> and will be ignored if set.</p>\n<p>If the <code>signal</code> option is enabled, calling <code>.abort()</code> on the corresponding\n<code>AbortController</code> is similar to calling <code>.kill()</code> on the child process except\nthe error passed to the callback will be an <code>AbortError</code>:</p>\n<pre><code class=\"language-cjs\">const { fork } = require('node:child_process');\n\nif (process.argv[2] === 'child') {\n  setTimeout(() => {\n    console.log(`Hello from ${process.argv[2]}!`);\n  }, 1_000);\n} else {\n  const controller = new AbortController();\n  const { signal } = controller;\n  const child = fork(__filename, ['child'], { signal });\n  child.on('error', (err) => {\n    // This will be called with err being an AbortError if the controller aborts\n  });\n  controller.abort(); // Stops the child process\n}\n</code></pre>\n<pre><code class=\"language-mjs\">import { fork } from 'node:child_process';\nimport process from 'node:process';\n\nif (process.argv[2] === 'child') {\n  setTimeout(() => {\n    console.log(`Hello from ${process.argv[2]}!`);\n  }, 1_000);\n} else {\n  const controller = new AbortController();\n  const { signal } = controller;\n  const child = fork(import.meta.url, ['child'], { signal });\n  child.on('error', (err) => {\n    // This will be called with err being an AbortError if the controller aborts\n  });\n  controller.abort(); // Stops the child process\n}\n</code></pre>"
            },
            {
              "textRaw": "`child_process.spawn(command[, args][, options])`",
              "name": "spawn",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.11.0",
                      "v22.15.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/57389",
                    "description": "Passing `args` when `shell` is set to `true` is deprecated."
                  },
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": [
                      "v15.13.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/37256",
                    "description": "timeout was added."
                  },
                  {
                    "version": [
                      "v15.11.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/37325",
                    "description": "killSignal for AbortSignal was added."
                  },
                  {
                    "version": [
                      "v15.5.0",
                      "v14.17.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/36432",
                    "description": "AbortSignal support was added."
                  },
                  {
                    "version": [
                      "v13.2.0",
                      "v12.16.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/30162",
                    "description": "The `serialization` option is supported now."
                  },
                  {
                    "version": "v8.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/15380",
                    "description": "The `windowsHide` option is supported now."
                  },
                  {
                    "version": "v6.4.0",
                    "pr-url": "https://github.com/nodejs/node/pull/7696",
                    "description": "The `argv0` option is supported now."
                  },
                  {
                    "version": "v5.7.0",
                    "pr-url": "https://github.com/nodejs/node/pull/4598",
                    "description": "The `shell` option is supported now."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`command` {string} The command to run.",
                      "name": "command",
                      "type": "string",
                      "desc": "The command to run."
                    },
                    {
                      "textRaw": "`args` {string}[] List of string arguments.",
                      "name": "args",
                      "type": "string",
                      "desc": "[] List of string arguments.",
                      "optional": true
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process.",
                          "name": "cwd",
                          "type": "string|URL",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`argv0` {string} Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` if not specified.",
                          "name": "argv0",
                          "type": "string",
                          "desc": "Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` if not specified."
                        },
                        {
                          "textRaw": "`stdio` {Array|string} Child's stdio configuration (see `options.stdio`).",
                          "name": "stdio",
                          "type": "Array|string",
                          "desc": "Child's stdio configuration (see `options.stdio`)."
                        },
                        {
                          "textRaw": "`detached` {boolean} Prepare child process to run independently of its parent process. Specific behavior depends on the platform (see `options.detached`).",
                          "name": "detached",
                          "type": "boolean",
                          "desc": "Prepare child process to run independently of its parent process. Specific behavior depends on the platform (see `options.detached`)."
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process (see `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process (see `setuid(2)`)."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process (see `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process (see `setgid(2)`)."
                        },
                        {
                          "textRaw": "`serialization` {string} Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. See Advanced serialization for more details. **Default:** `'json'`.",
                          "name": "serialization",
                          "type": "string",
                          "default": "`'json'`",
                          "desc": "Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`. See Advanced serialization for more details."
                        },
                        {
                          "textRaw": "`shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell. **Default:** `false` (no shell).",
                          "name": "shell",
                          "type": "boolean|string",
                          "default": "`false` (no shell)",
                          "desc": "If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell."
                        },
                        {
                          "textRaw": "`windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to `true` automatically when `shell` is specified and is CMD. **Default:** `false`.",
                          "name": "windowsVerbatimArguments",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to `true` automatically when `shell` is specified and is CMD."
                        },
                        {
                          "textRaw": "`windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`.",
                          "name": "windowsHide",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Hide the subprocess console window that would normally be created on Windows systems."
                        },
                        {
                          "textRaw": "`signal` {AbortSignal} allows aborting the child process using an AbortSignal.",
                          "name": "signal",
                          "type": "AbortSignal",
                          "desc": "allows aborting the child process using an AbortSignal."
                        },
                        {
                          "textRaw": "`timeout` {number} In milliseconds the maximum amount of time the process is allowed to run. **Default:** `undefined`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`undefined`",
                          "desc": "In milliseconds the maximum amount of time the process is allowed to run."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} The signal value to be used when the spawned process will be killed by timeout or abort signal. **Default:** `'SIGTERM'`.",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`",
                          "desc": "The signal value to be used when the spawned process will be killed by timeout or abort signal."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {ChildProcess}",
                    "name": "return",
                    "type": "ChildProcess"
                  }
                }
              ],
              "desc": "<p>The <code>child_process.spawn()</code> method spawns a new process using the given\n<code>command</code>, with command-line arguments in <code>args</code>. If omitted, <code>args</code> defaults\nto an empty array.</p>\n<p><strong>If the <code>shell</code> option is enabled, do not pass unsanitized user input to this\nfunction. Any input containing shell metacharacters may be used to trigger\narbitrary command execution.</strong></p>\n<p>A third argument may be used to specify additional options, with these defaults:</p>\n<pre><code class=\"language-js\">const defaults = {\n  cwd: undefined,\n  env: process.env,\n};\n</code></pre>\n<p>Use <code>cwd</code> to specify the working directory from which the process is spawned.\nIf not given, the default is to inherit the current working directory. If given,\nbut the path does not exist, the child process emits an <code>ENOENT</code> error\nand exits immediately. <code>ENOENT</code> is also emitted when the command\ndoes not exist.</p>\n<p>Use <code>env</code> to specify environment variables that will be visible to the new\nprocess, the default is <a href=\"process.html#processenv\"><code>process.env</code></a>.</p>\n<p><code>undefined</code> values in <code>env</code> will be ignored.</p>\n<p>Example of running <code>ls -lh /usr</code>, capturing <code>stdout</code>, <code>stderr</code>, and the\nexit code:</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst ls = spawn('ls', ['-lh', '/usr']);\n\nls.stdout.on('data', (data) => {\n  console.log(`stdout: ${data}`);\n});\n\nls.stderr.on('data', (data) => {\n  console.error(`stderr: ${data}`);\n});\n\nls.on('close', (code) => {\n  console.log(`child process exited with code ${code}`);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport { once } from 'node:events';\nconst ls = spawn('ls', ['-lh', '/usr']);\n\nls.stdout.on('data', (data) => {\n  console.log(`stdout: ${data}`);\n});\n\nls.stderr.on('data', (data) => {\n  console.error(`stderr: ${data}`);\n});\n\nconst [code] = await once(ls, 'close');\nconsole.log(`child process exited with code ${code}`);\n</code></pre>\n<p>Example: A very elaborate way to run <code>ps ax | grep ssh</code></p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst ps = spawn('ps', ['ax']);\nconst grep = spawn('grep', ['ssh']);\n\nps.stdout.on('data', (data) => {\n  grep.stdin.write(data);\n});\n\nps.stderr.on('data', (data) => {\n  console.error(`ps stderr: ${data}`);\n});\n\nps.on('close', (code) => {\n  if (code !== 0) {\n    console.log(`ps process exited with code ${code}`);\n  }\n  grep.stdin.end();\n});\n\ngrep.stdout.on('data', (data) => {\n  console.log(data.toString());\n});\n\ngrep.stderr.on('data', (data) => {\n  console.error(`grep stderr: ${data}`);\n});\n\ngrep.on('close', (code) => {\n  if (code !== 0) {\n    console.log(`grep process exited with code ${code}`);\n  }\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nconst ps = spawn('ps', ['ax']);\nconst grep = spawn('grep', ['ssh']);\n\nps.stdout.on('data', (data) => {\n  grep.stdin.write(data);\n});\n\nps.stderr.on('data', (data) => {\n  console.error(`ps stderr: ${data}`);\n});\n\nps.on('close', (code) => {\n  if (code !== 0) {\n    console.log(`ps process exited with code ${code}`);\n  }\n  grep.stdin.end();\n});\n\ngrep.stdout.on('data', (data) => {\n  console.log(data.toString());\n});\n\ngrep.stderr.on('data', (data) => {\n  console.error(`grep stderr: ${data}`);\n});\n\ngrep.on('close', (code) => {\n  if (code !== 0) {\n    console.log(`grep process exited with code ${code}`);\n  }\n});\n</code></pre>\n<p>Example of checking for failed <code>spawn</code>:</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst subprocess = spawn('bad_command');\n\nsubprocess.on('error', (err) => {\n  console.error('Failed to start subprocess.');\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nconst subprocess = spawn('bad_command');\n\nsubprocess.on('error', (err) => {\n  console.error('Failed to start subprocess.');\n});\n</code></pre>\n<p>Certain platforms (macOS, Linux) will use the value of <code>argv[0]</code> for the process\ntitle while others (Windows, SunOS) will use <code>command</code>.</p>\n<p>Node.js overwrites <code>argv[0]</code> with <code>process.execPath</code> on startup, so\n<code>process.argv[0]</code> in a Node.js child process will not match the <code>argv0</code>\nparameter passed to <code>spawn</code> from the parent. Retrieve it with the\n<code>process.argv0</code> property instead.</p>\n<p>If the <code>signal</code> option is enabled, calling <code>.abort()</code> on the corresponding\n<code>AbortController</code> is similar to calling <code>.kill()</code> on the child process except\nthe error passed to the callback will be an <code>AbortError</code>:</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst controller = new AbortController();\nconst { signal } = controller;\nconst grep = spawn('grep', ['ssh'], { signal });\ngrep.on('error', (err) => {\n  // This will be called with err being an AbortError if the controller aborts\n});\ncontroller.abort(); // Stops the child process\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nconst controller = new AbortController();\nconst { signal } = controller;\nconst grep = spawn('grep', ['ssh'], { signal });\ngrep.on('error', (err) => {\n  // This will be called with err being an AbortError if the controller aborts\n});\ncontroller.abort(); // Stops the child process\n</code></pre>",
              "properties": [
                {
                  "textRaw": "`options.detached`",
                  "name": "detached",
                  "type": "property",
                  "meta": {
                    "added": [
                      "v0.7.10"
                    ],
                    "changes": []
                  },
                  "desc": "<p>On Windows, setting <code>options.detached</code> to <code>true</code> makes it possible for the\nchild process to continue running after the parent exits. The child process\nwill have its own console window. Once enabled for a child process,\nit cannot be disabled.</p>\n<p>On non-Windows platforms, if <code>options.detached</code> is set to <code>true</code>, the child\nprocess will be made the leader of a new process group and session. Child\nprocesses may continue running after the parent exits regardless of whether\nthey are detached or not. See <a href=\"http://man7.org/linux/man-pages/man2/setsid.2.html\"><code>setsid(2)</code></a> for more information.</p>\n<p>By default, the parent will wait for the detached child process to exit.\nTo prevent the parent process from waiting for a given <code>subprocess</code> to exit, use\nthe <code>subprocess.unref()</code> method. Doing so will cause the parent process' event\nloop to not include the child process in its reference count, allowing the\nparent process to exit independently of the child process, unless there is an established\nIPC channel between the child and the parent processes.</p>\n<p>When using the <code>detached</code> option to start a long-running process, the process\nwill not stay running in the background after the parent exits unless it is\nprovided with a <code>stdio</code> configuration that is not connected to the parent.\nIf the parent process' <code>stdio</code> is inherited, the child process will remain attached\nto the controlling terminal.</p>\n<p>Example of a long-running process, by detaching and also ignoring its parent\n<code>stdio</code> file descriptors, in order to ignore the parent's termination:</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\n\nconst subprocess = spawn(process.argv[0], ['child_program.js'], {\n  detached: true,\n  stdio: 'ignore',\n});\n\nsubprocess.unref();\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport process from 'node:process';\n\nconst subprocess = spawn(process.argv[0], ['child_program.js'], {\n  detached: true,\n  stdio: 'ignore',\n});\n\nsubprocess.unref();\n</code></pre>\n<p>Alternatively one can redirect the child process' output into files:</p>\n<pre><code class=\"language-cjs\">const { openSync } = require('node:fs');\nconst { spawn } = require('node:child_process');\nconst out = openSync('./out.log', 'a');\nconst err = openSync('./out.log', 'a');\n\nconst subprocess = spawn('prg', [], {\n  detached: true,\n  stdio: [ 'ignore', out, err ],\n});\n\nsubprocess.unref();\n</code></pre>\n<pre><code class=\"language-mjs\">import { openSync } from 'node:fs';\nimport { spawn } from 'node:child_process';\nconst out = openSync('./out.log', 'a');\nconst err = openSync('./out.log', 'a');\n\nconst subprocess = spawn('prg', [], {\n  detached: true,\n  stdio: [ 'ignore', out, err ],\n});\n\nsubprocess.unref();\n</code></pre>"
                },
                {
                  "textRaw": "`options.stdio`",
                  "name": "stdio",
                  "type": "property",
                  "meta": {
                    "added": [
                      "v0.7.10"
                    ],
                    "changes": [
                      {
                        "version": [
                          "v15.6.0",
                          "v14.18.0"
                        ],
                        "pr-url": "https://github.com/nodejs/node/pull/29412",
                        "description": "Added the `overlapped` stdio flag."
                      },
                      {
                        "version": "v3.3.1",
                        "pr-url": "https://github.com/nodejs/node/pull/2727",
                        "description": "The value `0` is now accepted as a file descriptor."
                      }
                    ]
                  },
                  "desc": "<p>The <code>options.stdio</code> option is used to configure the pipes that are established\nbetween the parent and child process. By default, the child's stdin, stdout,\nand stderr are redirected to corresponding <a href=\"#subprocessstdin\"><code>subprocess.stdin</code></a>,\n<a href=\"#subprocessstdout\"><code>subprocess.stdout</code></a>, and <a href=\"#subprocessstderr\"><code>subprocess.stderr</code></a> streams on the\n<a href=\"#class-childprocess\"><code>ChildProcess</code></a> object. This is equivalent to setting the <code>options.stdio</code>\nequal to <code>['pipe', 'pipe', 'pipe']</code>.</p>\n<p>For convenience, <code>options.stdio</code> may be one of the following strings:</p>\n<ul>\n<li><code>'pipe'</code>: equivalent to <code>['pipe', 'pipe', 'pipe']</code> (the default)</li>\n<li><code>'overlapped'</code>: equivalent to <code>['overlapped', 'overlapped', 'overlapped']</code></li>\n<li><code>'ignore'</code>: equivalent to <code>['ignore', 'ignore', 'ignore']</code></li>\n<li><code>'inherit'</code>: equivalent to <code>['inherit', 'inherit', 'inherit']</code> or <code>[0, 1, 2]</code></li>\n</ul>\n<p>Otherwise, the value of <code>options.stdio</code> is an array where each index corresponds\nto an fd in the child. The fds 0, 1, and 2 correspond to stdin, stdout,\nand stderr, respectively. Additional fds can be specified to create additional\npipes between the parent and child. The value is one of the following:</p>\n<ol>\n<li>\n<p><code>'pipe'</code>: Create a pipe between the child process and the parent process.\nThe parent end of the pipe is exposed to the parent as a property on the\n<code>child_process</code> object as <a href=\"#subprocessstdio\"><code>subprocess.stdio[fd]</code></a>. Pipes\ncreated for fds 0, 1, and 2 are also available as <a href=\"#subprocessstdin\"><code>subprocess.stdin</code></a>,\n<a href=\"#subprocessstdout\"><code>subprocess.stdout</code></a> and <a href=\"#subprocessstderr\"><code>subprocess.stderr</code></a>, respectively.\nThese are not actual Unix pipes and therefore the child process\ncan not use them by their descriptor files,\ne.g. <code>/dev/fd/2</code> or <code>/dev/stdout</code>.</p>\n</li>\n<li>\n<p><code>'overlapped'</code>: Same as <code>'pipe'</code> except that the <code>FILE_FLAG_OVERLAPPED</code> flag\nis set on the handle. This is necessary for overlapped I/O on the child\nprocess's stdio handles. See the\n<a href=\"https://docs.microsoft.com/en-us/windows/win32/fileio/synchronous-and-asynchronous-i-o\">docs</a>\nfor more details. This is exactly the same as <code>'pipe'</code> on non-Windows\nsystems.</p>\n</li>\n<li>\n<p><code>'ipc'</code>: Create an IPC channel for passing messages/file descriptors\nbetween parent and child. A <a href=\"#class-childprocess\"><code>ChildProcess</code></a> may have at most one IPC\nstdio file descriptor. Setting this option enables the\n<a href=\"#subprocesssendmessage-sendhandle-options-callback\"><code>subprocess.send()</code></a> method. If the child process is a Node.js instance,\nthe presence of an IPC channel will enable <a href=\"process.html#processsendmessage-sendhandle-options-callback\"><code>process.send()</code></a> and\n<a href=\"process.html#processdisconnect\"><code>process.disconnect()</code></a> methods, as well as <a href=\"process.html#event-disconnect\"><code>'disconnect'</code></a> and\n<a href=\"process.html#event-message\"><code>'message'</code></a> events within the child process.</p>\n<p>Accessing the IPC channel fd in any way other than <a href=\"process.html#processsendmessage-sendhandle-options-callback\"><code>process.send()</code></a>\nor using the IPC channel with a child process that is not a Node.js instance\nis not supported.</p>\n</li>\n<li>\n<p><code>'ignore'</code>: Instructs Node.js to ignore the fd in the child. While Node.js\nwill always open fds 0, 1, and 2 for the processes it spawns, setting the fd\nto <code>'ignore'</code> will cause Node.js to open <code>/dev/null</code> and attach it to the\nchild's fd.</p>\n</li>\n<li>\n<p><code>'inherit'</code>: Pass through the corresponding stdio stream to/from the\nparent process. In the first three positions, this is equivalent to\n<code>process.stdin</code>, <code>process.stdout</code>, and <code>process.stderr</code>, respectively. In\nany other position, equivalent to <code>'ignore'</code>.</p>\n</li>\n<li>\n<p><a href=\"stream.html#stream\"><code>&#x3C;Stream></code></a> object: Share a readable or writable stream that refers to a tty,\nfile, socket, or a pipe with the child process. The stream's underlying\nfile descriptor is duplicated in the child process to the fd that\ncorresponds to the index in the <code>stdio</code> array. The stream must have an\nunderlying descriptor (file streams do not start until the <code>'open'</code> event has\noccurred).\n<strong>NOTE:</strong> While it is technically possible to pass <code>stdin</code> as a writable or\n<code>stdout</code>/<code>stderr</code> as readable, it is not recommended.\nReadable and writable streams are designed with distinct behaviors, and using\nthem incorrectly (e.g., passing a readable stream where a writable stream is\nexpected) can lead to unexpected results or errors. This practice is discouraged\nas it may result in undefined behavior or dropped callbacks if the stream\nencounters errors. Always ensure that <code>stdin</code> is used as readable and\n<code>stdout</code>/<code>stderr</code> as writable to maintain the intended flow of data between\nthe parent and child processes.</p>\n</li>\n<li>\n<p>Positive integer: The integer value is interpreted as a file descriptor\nthat is open in the parent process. It is shared with the child\nprocess, similar to how <a href=\"stream.html#stream\"><code>&#x3C;Stream></code></a> objects can be shared. Passing sockets\nis not supported on Windows.</p>\n</li>\n<li>\n<p><code>null</code>, <code>undefined</code>: Use default value. For stdio fds 0, 1, and 2 (in other\nwords, stdin, stdout, and stderr) a pipe is created. For fd 3 and up, the\ndefault is <code>'ignore'</code>.</p>\n</li>\n</ol>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\n\n// Child will use parent's stdios.\nspawn('prg', [], { stdio: 'inherit' });\n\n// Spawn child sharing only stderr.\nspawn('prg', [], { stdio: ['pipe', 'pipe', process.stderr] });\n\n// Open an extra fd=4, to interact with programs presenting a\n// startd-style interface.\nspawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] });\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport process from 'node:process';\n\n// Child will use parent's stdios.\nspawn('prg', [], { stdio: 'inherit' });\n\n// Spawn child sharing only stderr.\nspawn('prg', [], { stdio: ['pipe', 'pipe', process.stderr] });\n\n// Open an extra fd=4, to interact with programs presenting a\n// startd-style interface.\nspawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] });\n</code></pre>\n<p><em>It is worth noting that when an IPC channel is established between the\nparent and child processes, and the child process is a Node.js instance,\nthe child process is launched with the IPC channel unreferenced (using\n<code>unref()</code>) until the child process registers an event handler for the\n<a href=\"process.html#event-disconnect\"><code>'disconnect'</code></a> event or the <a href=\"process.html#event-message\"><code>'message'</code></a> event. This allows the\nchild process to exit normally without the process being held open by the\nopen IPC channel.</em>\nSee also: <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> and <a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>.</p>"
                }
              ]
            }
          ],
          "displayName": "Asynchronous process creation"
        },
        {
          "textRaw": "Synchronous process creation",
          "name": "synchronous_process_creation",
          "type": "module",
          "desc": "<p>The <a href=\"#child_processspawnsynccommand-args-options\"><code>child_process.spawnSync()</code></a>, <a href=\"#child_processexecsynccommand-options\"><code>child_process.execSync()</code></a>, and\n<a href=\"#child_processexecfilesyncfile-args-options\"><code>child_process.execFileSync()</code></a> methods are synchronous and will block the\nNode.js event loop, pausing execution of any additional code until the spawned\nprocess exits.</p>\n<p>Blocking calls like these are mostly useful for simplifying general-purpose\nscripting tasks and for simplifying the loading/processing of application\nconfiguration at startup.</p>",
          "methods": [
            {
              "textRaw": "`child_process.execFileSync(file[, args][, options])`",
              "name": "execFileSync",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.12"
                ],
                "changes": [
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": "v10.10.0",
                    "pr-url": "https://github.com/nodejs/node/pull/22409",
                    "description": "The `input` option can now be any `TypedArray` or a `DataView`."
                  },
                  {
                    "version": "v8.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/15380",
                    "description": "The `windowsHide` option is supported now."
                  },
                  {
                    "version": "v8.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/10653",
                    "description": "The `input` option can now be a `Uint8Array`."
                  },
                  {
                    "version": [
                      "v6.2.1",
                      "v4.5.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/6939",
                    "description": "The `encoding` option can now explicitly be set to `buffer`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`file` {string} The name or path of the executable file to run.",
                      "name": "file",
                      "type": "string",
                      "desc": "The name or path of the executable file to run."
                    },
                    {
                      "textRaw": "`args` {string}[] List of string arguments.",
                      "name": "args",
                      "type": "string",
                      "desc": "[] List of string arguments.",
                      "optional": true
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process.",
                          "name": "cwd",
                          "type": "string|URL",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`input` {string|Buffer|TypedArray|DataView} The value which will be passed as stdin to the spawned process. If `stdio[0]` is set to `'pipe'`, Supplying this value will override `stdio[0]`.",
                          "name": "input",
                          "type": "string|Buffer|TypedArray|DataView",
                          "desc": "The value which will be passed as stdin to the spawned process. If `stdio[0]` is set to `'pipe'`, Supplying this value will override `stdio[0]`."
                        },
                        {
                          "textRaw": "`stdio` {string|Array} Child's stdio configuration. See `child_process.spawn()`'s `stdio`. `stderr` by default will be output to the parent process' stderr unless `stdio` is specified. **Default:** `'pipe'`.",
                          "name": "stdio",
                          "type": "string|Array",
                          "default": "`'pipe'`",
                          "desc": "Child's stdio configuration. See `child_process.spawn()`'s `stdio`. `stderr` by default will be output to the parent process' stderr unless `stdio` is specified."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process (see `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process (see `setuid(2)`)."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process (see `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process (see `setgid(2)`)."
                        },
                        {
                          "textRaw": "`timeout` {number} In milliseconds the maximum amount of time the process is allowed to run. **Default:** `undefined`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`undefined`",
                          "desc": "In milliseconds the maximum amount of time the process is allowed to run."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} The signal value to be used when the spawned process will be killed. **Default:** `'SIGTERM'`.",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`",
                          "desc": "The signal value to be used when the spawned process will be killed."
                        },
                        {
                          "textRaw": "`maxBuffer` {number} Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated. See caveat at `maxBuffer` and Unicode. **Default:** `1024 * 1024`.",
                          "name": "maxBuffer",
                          "type": "number",
                          "default": "`1024 * 1024`",
                          "desc": "Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated. See caveat at `maxBuffer` and Unicode."
                        },
                        {
                          "textRaw": "`encoding` {string} The encoding used for all stdio inputs and outputs. **Default:** `'buffer'`.",
                          "name": "encoding",
                          "type": "string",
                          "default": "`'buffer'`",
                          "desc": "The encoding used for all stdio inputs and outputs."
                        },
                        {
                          "textRaw": "`windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`.",
                          "name": "windowsHide",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Hide the subprocess console window that would normally be created on Windows systems."
                        },
                        {
                          "textRaw": "`shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell. **Default:** `false` (no shell).",
                          "name": "shell",
                          "type": "boolean|string",
                          "default": "`false` (no shell)",
                          "desc": "If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Buffer|string} The stdout from the command.",
                    "name": "return",
                    "type": "Buffer|string",
                    "desc": "The stdout from the command."
                  }
                }
              ],
              "desc": "<p>The <code>child_process.execFileSync()</code> method is generally identical to\n<a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a> with the exception that the method will not\nreturn until the child process has fully closed. When a timeout has been\nencountered and <code>killSignal</code> is sent, the method won't return until the process\nhas completely exited.</p>\n<p>If the child process intercepts and handles the <code>SIGTERM</code> signal and\ndoes not exit, the parent process will still wait until the child process has\nexited.</p>\n<p>If the process times out or has a non-zero exit code, this method will throw an\n<a href=\"errors.html#class-error\"><code>Error</code></a> that will include the full result of the underlying\n<a href=\"#child_processspawnsynccommand-args-options\"><code>child_process.spawnSync()</code></a>.</p>\n<p><strong>If the <code>shell</code> option is enabled, do not pass unsanitized user input to this\nfunction. Any input containing shell metacharacters may be used to trigger\narbitrary command execution.</strong></p>\n<pre><code class=\"language-cjs\">const { execFileSync } = require('node:child_process');\n\ntry {\n  const stdout = execFileSync('my-script.sh', ['my-arg'], {\n    // Capture stdout and stderr from child process. Overrides the\n    // default behavior of streaming child stderr to the parent stderr\n    stdio: 'pipe',\n\n    // Use utf8 encoding for stdio pipes\n    encoding: 'utf8',\n  });\n\n  console.log(stdout);\n} catch (err) {\n  if (err.code) {\n    // Spawning child process failed\n    console.error(err.code);\n  } else {\n    // Child was spawned but exited with non-zero exit code\n    // Error contains any stdout and stderr from the child\n    const { stdout, stderr } = err;\n\n    console.error({ stdout, stderr });\n  }\n}\n</code></pre>\n<pre><code class=\"language-mjs\">import { execFileSync } from 'node:child_process';\n\ntry {\n  const stdout = execFileSync('my-script.sh', ['my-arg'], {\n    // Capture stdout and stderr from child process. Overrides the\n    // default behavior of streaming child stderr to the parent stderr\n    stdio: 'pipe',\n\n    // Use utf8 encoding for stdio pipes\n    encoding: 'utf8',\n  });\n\n  console.log(stdout);\n} catch (err) {\n  if (err.code) {\n    // Spawning child process failed\n    console.error(err.code);\n  } else {\n    // Child was spawned but exited with non-zero exit code\n    // Error contains any stdout and stderr from the child\n    const { stdout, stderr } = err;\n\n    console.error({ stdout, stderr });\n  }\n}\n</code></pre>"
            },
            {
              "textRaw": "`child_process.execSync(command[, options])`",
              "name": "execSync",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.12"
                ],
                "changes": [
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": "v10.10.0",
                    "pr-url": "https://github.com/nodejs/node/pull/22409",
                    "description": "The `input` option can now be any `TypedArray` or a `DataView`."
                  },
                  {
                    "version": "v8.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/15380",
                    "description": "The `windowsHide` option is supported now."
                  },
                  {
                    "version": "v8.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/10653",
                    "description": "The `input` option can now be a `Uint8Array`."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`command` {string} The command to run.",
                      "name": "command",
                      "type": "string",
                      "desc": "The command to run."
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process.",
                          "name": "cwd",
                          "type": "string|URL",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`input` {string|Buffer|TypedArray|DataView} The value which will be passed as stdin to the spawned process. If `stdio[0]` is set to `'pipe'`, Supplying this value will override `stdio[0]`.",
                          "name": "input",
                          "type": "string|Buffer|TypedArray|DataView",
                          "desc": "The value which will be passed as stdin to the spawned process. If `stdio[0]` is set to `'pipe'`, Supplying this value will override `stdio[0]`."
                        },
                        {
                          "textRaw": "`stdio` {string|Array} Child's stdio configuration. See `child_process.spawn()`'s `stdio`. `stderr` by default will be output to the parent process' stderr unless `stdio` is specified. **Default:** `'pipe'`.",
                          "name": "stdio",
                          "type": "string|Array",
                          "default": "`'pipe'`",
                          "desc": "Child's stdio configuration. See `child_process.spawn()`'s `stdio`. `stderr` by default will be output to the parent process' stderr unless `stdio` is specified."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`shell` {string} Shell to execute the command with. See Shell requirements and Default Windows shell. **Default:** `'/bin/sh'` on Unix, `process.env.ComSpec` on Windows.",
                          "name": "shell",
                          "type": "string",
                          "default": "`'/bin/sh'` on Unix, `process.env.ComSpec` on Windows",
                          "desc": "Shell to execute the command with. See Shell requirements and Default Windows shell."
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process. (See `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process. (See `setuid(2)`)."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process. (See `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process. (See `setgid(2)`)."
                        },
                        {
                          "textRaw": "`timeout` {number} In milliseconds the maximum amount of time the process is allowed to run. **Default:** `undefined`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`undefined`",
                          "desc": "In milliseconds the maximum amount of time the process is allowed to run."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} The signal value to be used when the spawned process will be killed. **Default:** `'SIGTERM'`.",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`",
                          "desc": "The signal value to be used when the spawned process will be killed."
                        },
                        {
                          "textRaw": "`maxBuffer` {number} Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode. **Default:** `1024 * 1024`.",
                          "name": "maxBuffer",
                          "type": "number",
                          "default": "`1024 * 1024`",
                          "desc": "Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode."
                        },
                        {
                          "textRaw": "`encoding` {string} The encoding used for all stdio inputs and outputs. **Default:** `'buffer'`.",
                          "name": "encoding",
                          "type": "string",
                          "default": "`'buffer'`",
                          "desc": "The encoding used for all stdio inputs and outputs."
                        },
                        {
                          "textRaw": "`windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`.",
                          "name": "windowsHide",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Hide the subprocess console window that would normally be created on Windows systems."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Buffer|string} The stdout from the command.",
                    "name": "return",
                    "type": "Buffer|string",
                    "desc": "The stdout from the command."
                  }
                }
              ],
              "desc": "<p>The <code>child_process.execSync()</code> method is generally identical to\n<a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a> with the exception that the method will not return\nuntil the child process has fully closed. When a timeout has been encountered\nand <code>killSignal</code> is sent, the method won't return until the process has\ncompletely exited. If the child process intercepts and handles the <code>SIGTERM</code>\nsignal and doesn't exit, the parent process will wait until the child process\nhas exited.</p>\n<p>If the process times out or has a non-zero exit code, this method will throw.\nThe <a href=\"errors.html#class-error\"><code>Error</code></a> object will contain the entire result from\n<a href=\"#child_processspawnsynccommand-args-options\"><code>child_process.spawnSync()</code></a>.</p>\n<p><strong>Never pass unsanitized user input to this function. Any input containing shell\nmetacharacters may be used to trigger arbitrary command execution.</strong></p>"
            },
            {
              "textRaw": "`child_process.spawnSync(command[, args][, options])`",
              "name": "spawnSync",
              "type": "method",
              "meta": {
                "added": [
                  "v0.11.12"
                ],
                "changes": [
                  {
                    "version": [
                      "v16.4.0",
                      "v14.18.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/38862",
                    "description": "The `cwd` option can be a WHATWG `URL` object using `file:` protocol."
                  },
                  {
                    "version": "v10.10.0",
                    "pr-url": "https://github.com/nodejs/node/pull/22409",
                    "description": "The `input` option can now be any `TypedArray` or a `DataView`."
                  },
                  {
                    "version": "v8.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/15380",
                    "description": "The `windowsHide` option is supported now."
                  },
                  {
                    "version": "v8.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/10653",
                    "description": "The `input` option can now be a `Uint8Array`."
                  },
                  {
                    "version": [
                      "v6.2.1",
                      "v4.5.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/6939",
                    "description": "The `encoding` option can now explicitly be set to `buffer`."
                  },
                  {
                    "version": "v5.7.0",
                    "pr-url": "https://github.com/nodejs/node/pull/4598",
                    "description": "The `shell` option is supported now."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`command` {string} The command to run.",
                      "name": "command",
                      "type": "string",
                      "desc": "The command to run."
                    },
                    {
                      "textRaw": "`args` {string}[] List of string arguments.",
                      "name": "args",
                      "type": "string",
                      "desc": "[] List of string arguments.",
                      "optional": true
                    },
                    {
                      "textRaw": "`options` {Object}",
                      "name": "options",
                      "type": "Object",
                      "options": [
                        {
                          "textRaw": "`cwd` {string|URL} Current working directory of the child process.",
                          "name": "cwd",
                          "type": "string|URL",
                          "desc": "Current working directory of the child process."
                        },
                        {
                          "textRaw": "`input` {string|Buffer|TypedArray|DataView} The value which will be passed as stdin to the spawned process. If `stdio[0]` is set to `'pipe'`, Supplying this value will override `stdio[0]`.",
                          "name": "input",
                          "type": "string|Buffer|TypedArray|DataView",
                          "desc": "The value which will be passed as stdin to the spawned process. If `stdio[0]` is set to `'pipe'`, Supplying this value will override `stdio[0]`."
                        },
                        {
                          "textRaw": "`argv0` {string} Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` if not specified.",
                          "name": "argv0",
                          "type": "string",
                          "desc": "Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` if not specified."
                        },
                        {
                          "textRaw": "`stdio` {string|Array} Child's stdio configuration. See `child_process.spawn()`'s `stdio`. **Default:** `'pipe'`.",
                          "name": "stdio",
                          "type": "string|Array",
                          "default": "`'pipe'`",
                          "desc": "Child's stdio configuration. See `child_process.spawn()`'s `stdio`."
                        },
                        {
                          "textRaw": "`env` {Object} Environment key-value pairs. **Default:** `process.env`.",
                          "name": "env",
                          "type": "Object",
                          "default": "`process.env`",
                          "desc": "Environment key-value pairs."
                        },
                        {
                          "textRaw": "`uid` {number} Sets the user identity of the process (see `setuid(2)`).",
                          "name": "uid",
                          "type": "number",
                          "desc": "Sets the user identity of the process (see `setuid(2)`)."
                        },
                        {
                          "textRaw": "`gid` {number} Sets the group identity of the process (see `setgid(2)`).",
                          "name": "gid",
                          "type": "number",
                          "desc": "Sets the group identity of the process (see `setgid(2)`)."
                        },
                        {
                          "textRaw": "`timeout` {number} In milliseconds the maximum amount of time the process is allowed to run. **Default:** `undefined`.",
                          "name": "timeout",
                          "type": "number",
                          "default": "`undefined`",
                          "desc": "In milliseconds the maximum amount of time the process is allowed to run."
                        },
                        {
                          "textRaw": "`killSignal` {string|integer} The signal value to be used when the spawned process will be killed. **Default:** `'SIGTERM'`.",
                          "name": "killSignal",
                          "type": "string|integer",
                          "default": "`'SIGTERM'`",
                          "desc": "The signal value to be used when the spawned process will be killed."
                        },
                        {
                          "textRaw": "`maxBuffer` {number} Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode. **Default:** `1024 * 1024`.",
                          "name": "maxBuffer",
                          "type": "number",
                          "default": "`1024 * 1024`",
                          "desc": "Largest amount of data in bytes allowed on stdout or stderr. If exceeded, the child process is terminated and any output is truncated. See caveat at `maxBuffer` and Unicode."
                        },
                        {
                          "textRaw": "`encoding` {string} The encoding used for all stdio inputs and outputs. **Default:** `'buffer'`.",
                          "name": "encoding",
                          "type": "string",
                          "default": "`'buffer'`",
                          "desc": "The encoding used for all stdio inputs and outputs."
                        },
                        {
                          "textRaw": "`shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell. **Default:** `false` (no shell).",
                          "name": "shell",
                          "type": "boolean|string",
                          "default": "`false` (no shell)",
                          "desc": "If `true`, runs `command` inside of a shell. Uses `'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different shell can be specified as a string. See Shell requirements and Default Windows shell."
                        },
                        {
                          "textRaw": "`windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to `true` automatically when `shell` is specified and is CMD. **Default:** `false`.",
                          "name": "windowsVerbatimArguments",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to `true` automatically when `shell` is specified and is CMD."
                        },
                        {
                          "textRaw": "`windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`.",
                          "name": "windowsHide",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "Hide the subprocess console window that would normally be created on Windows systems."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object",
                    "options": [
                      {
                        "textRaw": "`pid` {number} Pid of the child process.",
                        "name": "pid",
                        "type": "number",
                        "desc": "Pid of the child process."
                      },
                      {
                        "textRaw": "`output` {Array} Array of results from stdio output.",
                        "name": "output",
                        "type": "Array",
                        "desc": "Array of results from stdio output."
                      },
                      {
                        "textRaw": "`stdout` {Buffer|string} The contents of `output[1]`.",
                        "name": "stdout",
                        "type": "Buffer|string",
                        "desc": "The contents of `output[1]`."
                      },
                      {
                        "textRaw": "`stderr` {Buffer|string} The contents of `output[2]`.",
                        "name": "stderr",
                        "type": "Buffer|string",
                        "desc": "The contents of `output[2]`."
                      },
                      {
                        "textRaw": "`status` {number|null} The exit code of the subprocess, or `null` if the subprocess terminated due to a signal.",
                        "name": "status",
                        "type": "number|null",
                        "desc": "The exit code of the subprocess, or `null` if the subprocess terminated due to a signal."
                      },
                      {
                        "textRaw": "`signal` {string|null} The signal used to kill the subprocess, or `null` if the subprocess did not terminate due to a signal.",
                        "name": "signal",
                        "type": "string|null",
                        "desc": "The signal used to kill the subprocess, or `null` if the subprocess did not terminate due to a signal."
                      },
                      {
                        "textRaw": "`error` {Error} The error object if the child process failed or timed out.",
                        "name": "error",
                        "type": "Error",
                        "desc": "The error object if the child process failed or timed out."
                      }
                    ]
                  }
                }
              ],
              "desc": "<p>The <code>child_process.spawnSync()</code> method is generally identical to\n<a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> with the exception that the function will not return\nuntil the child process has fully closed. When a timeout has been encountered\nand <code>killSignal</code> is sent, the method won't return until the process has\ncompletely exited. If the process intercepts and handles the <code>SIGTERM</code> signal\nand doesn't exit, the parent process will wait until the child process has\nexited.</p>\n<p><strong>If the <code>shell</code> option is enabled, do not pass unsanitized user input to this\nfunction. Any input containing shell metacharacters may be used to trigger\narbitrary command execution.</strong></p>"
            }
          ],
          "displayName": "Synchronous process creation"
        },
        {
          "textRaw": "`maxBuffer` and Unicode",
          "name": "`maxbuffer`_and_unicode",
          "type": "module",
          "desc": "<p>The <code>maxBuffer</code> option specifies the largest number of bytes allowed on <code>stdout</code>\nor <code>stderr</code>. If this value is exceeded, then the child process is terminated.\nThis impacts output that includes multibyte character encodings such as UTF-8 or\nUTF-16. For instance, <code>console.log('中文测试')</code> will send 13 UTF-8 encoded bytes\nto <code>stdout</code> although there are only 4 characters.</p>",
          "displayName": "`maxBuffer` and Unicode"
        },
        {
          "textRaw": "Shell requirements",
          "name": "shell_requirements",
          "type": "module",
          "desc": "<p>The shell should understand the <code>-c</code> switch. If the shell is <code>'cmd.exe'</code>, it\nshould understand the <code>/d /s /c</code> switches and command-line parsing should be\ncompatible.</p>",
          "displayName": "Shell requirements"
        },
        {
          "textRaw": "Default Windows shell",
          "name": "default_windows_shell",
          "type": "module",
          "desc": "<p>Although Microsoft specifies <code>%COMSPEC%</code> must contain the path to\n<code>'cmd.exe'</code> in the root environment, child processes are not always subject to\nthe same requirement. Thus, in <code>child_process</code> functions where a shell can be\nspawned, <code>'cmd.exe'</code> is used as a fallback if <code>process.env.ComSpec</code> is\nunavailable.</p>",
          "displayName": "Default Windows shell"
        },
        {
          "textRaw": "Advanced serialization",
          "name": "advanced_serialization",
          "type": "module",
          "meta": {
            "added": [
              "v13.2.0",
              "v12.16.0"
            ],
            "changes": []
          },
          "desc": "<p>Child processes support a serialization mechanism for IPC that is based on the\n<a href=\"v8.html#serialization-api\">serialization API of the <code>node:v8</code> module</a>, based on the\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\">HTML structured clone algorithm</a>. This is generally more powerful and\nsupports more built-in JavaScript object types, such as <code>BigInt</code>, <code>Map</code>\nand <code>Set</code>, <code>ArrayBuffer</code> and <code>TypedArray</code>, <code>Buffer</code>, <code>Error</code>, <code>RegExp</code> etc.</p>\n<p>However, this format is not a full superset of JSON, and e.g. properties set on\nobjects of such built-in types will not be passed on through the serialization\nstep. Additionally, performance may not be equivalent to that of JSON, depending\non the structure of the passed data.\nTherefore, this feature requires opting in by setting the\n<code>serialization</code> option to <code>'advanced'</code> when calling <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a>\nor <a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>.</p>",
          "displayName": "Advanced serialization"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `ChildProcess`",
          "name": "ChildProcess",
          "type": "class",
          "meta": {
            "added": [
              "v2.2.0"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"events.html#class-eventemitter\"><code>&#x3C;EventEmitter></code></a></li>\n</ul>\n<p>Instances of the <code>ChildProcess</code> represent spawned child processes.</p>\n<p>Instances of <code>ChildProcess</code> are not intended to be created directly. Rather,\nuse the <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a>, <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>,\n<a href=\"#child_processexecfilefile-args-options-callback\"><code>child_process.execFile()</code></a>, or <a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a> methods to create\ninstances of <code>ChildProcess</code>.</p>",
          "events": [
            {
              "textRaw": "Event: `'close'`",
              "name": "close",
              "type": "event",
              "meta": {
                "added": [
                  "v0.7.7"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`code` {number} The exit code if the child process exited on its own, or `null` if the child process terminated due to a signal.",
                  "name": "code",
                  "type": "number",
                  "desc": "The exit code if the child process exited on its own, or `null` if the child process terminated due to a signal."
                },
                {
                  "textRaw": "`signal` {string} The signal by which the child process was terminated, or `null` if the child process did not terminated due to a signal.",
                  "name": "signal",
                  "type": "string",
                  "desc": "The signal by which the child process was terminated, or `null` if the child process did not terminated due to a signal."
                }
              ],
              "desc": "<p>The <code>'close'</code> event is emitted after a process has ended <em>and</em> the stdio\nstreams of a child process have been closed. This is distinct from the\n<a href=\"#event-exit\"><code>'exit'</code></a> event, since multiple processes might share the same stdio\nstreams. The <code>'close'</code> event will always emit after <a href=\"#event-exit\"><code>'exit'</code></a> was\nalready emitted, or <a href=\"#event-error\"><code>'error'</code></a> if the child process failed to spawn.</p>\n<p>If the process exited, <code>code</code> is the final exit code of the process, otherwise\n<code>null</code>. If the process terminated due to receipt of a signal, <code>signal</code> is the\nstring name of the signal, otherwise <code>null</code>. One of the two will always be\nnon-<code>null</code>.</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst ls = spawn('ls', ['-lh', '/usr']);\n\nls.stdout.on('data', (data) => {\n  console.log(`stdout: ${data}`);\n});\n\nls.on('close', (code) => {\n  console.log(`child process close all stdio with code ${code}`);\n});\n\nls.on('exit', (code) => {\n  console.log(`child process exited with code ${code}`);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport { once } from 'node:events';\nconst ls = spawn('ls', ['-lh', '/usr']);\n\nls.stdout.on('data', (data) => {\n  console.log(`stdout: ${data}`);\n});\n\nls.on('close', (code) => {\n  console.log(`child process close all stdio with code ${code}`);\n});\n\nls.on('exit', (code) => {\n  console.log(`child process exited with code ${code}`);\n});\n\nconst [code] = await once(ls, 'close');\nconsole.log(`child process close all stdio with code ${code}`);\n</code></pre>"
            },
            {
              "textRaw": "Event: `'disconnect'`",
              "name": "disconnect",
              "type": "event",
              "meta": {
                "added": [
                  "v0.7.2"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>The <code>'disconnect'</code> event is emitted after calling the\n<a href=\"#subprocessdisconnect\"><code>subprocess.disconnect()</code></a> method in parent process or\n<a href=\"process.html#processdisconnect\"><code>process.disconnect()</code></a> in child process. After disconnecting it is no longer\npossible to send or receive messages, and the <a href=\"#subprocessconnected\"><code>subprocess.connected</code></a>\nproperty is <code>false</code>.</p>"
            },
            {
              "textRaw": "Event: `'error'`",
              "name": "error",
              "type": "event",
              "params": [
                {
                  "textRaw": "`err` {Error} The error.",
                  "name": "err",
                  "type": "Error",
                  "desc": "The error."
                }
              ],
              "desc": "<p>The <code>'error'</code> event is emitted whenever:</p>\n<ul>\n<li>The process could not be spawned.</li>\n<li>The process could not be killed.</li>\n<li>Sending a message to the child process failed.</li>\n<li>The child process was aborted via the <code>signal</code> option.</li>\n</ul>\n<p>The <code>'exit'</code> event may or may not fire after an error has occurred. When\nlistening to both the <code>'exit'</code> and <code>'error'</code> events, guard\nagainst accidentally invoking handler functions multiple times.</p>\n<p>See also <a href=\"#subprocesskillsignal\"><code>subprocess.kill()</code></a> and <a href=\"#subprocesssendmessage-sendhandle-options-callback\"><code>subprocess.send()</code></a>.</p>"
            },
            {
              "textRaw": "Event: `'exit'`",
              "name": "exit",
              "type": "event",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`code` {number} The exit code if the child process exited on its own, or `null` if the child process terminated due to a signal.",
                  "name": "code",
                  "type": "number",
                  "desc": "The exit code if the child process exited on its own, or `null` if the child process terminated due to a signal."
                },
                {
                  "textRaw": "`signal` {string} The signal by which the child process was terminated, or `null` if the child process did not terminated due to a signal.",
                  "name": "signal",
                  "type": "string",
                  "desc": "The signal by which the child process was terminated, or `null` if the child process did not terminated due to a signal."
                }
              ],
              "desc": "<p>The <code>'exit'</code> event is emitted after the child process ends. If the process\nexited, <code>code</code> is the final exit code of the process, otherwise <code>null</code>. If the\nprocess terminated due to receipt of a signal, <code>signal</code> is the string name of\nthe signal, otherwise <code>null</code>. One of the two will always be non-<code>null</code>.</p>\n<p>When the <code>'exit'</code> event is triggered, child process stdio streams might still be\nopen.</p>\n<p>Node.js establishes signal handlers for <code>SIGINT</code> and <code>SIGTERM</code> and Node.js\nprocesses will not terminate immediately due to receipt of those signals.\nRather, Node.js will perform a sequence of cleanup actions and then will\nre-raise the handled signal.</p>\n<p>See <a href=\"http://man7.org/linux/man-pages/man2/waitpid.2.html\"><code>waitpid(2)</code></a>.</p>\n<p>When <code>code</code> is <code>null</code> due to signal termination, you can use\n<a href=\"util.html#utilconvertprocesssignaltoexitcodesignal\"><code>util.convertProcessSignalToExitCode()</code></a> to convert the signal to a POSIX\nexit code.</p>"
            },
            {
              "textRaw": "Event: `'message'`",
              "name": "message",
              "type": "event",
              "meta": {
                "added": [
                  "v0.5.9"
                ],
                "changes": []
              },
              "params": [
                {
                  "textRaw": "`message` {Object} A parsed JSON object or primitive value.",
                  "name": "message",
                  "type": "Object",
                  "desc": "A parsed JSON object or primitive value."
                },
                {
                  "textRaw": "`sendHandle` {Handle|undefined} `undefined` or a `net.Socket`, `net.Server`, or `dgram.Socket` object.",
                  "name": "sendHandle",
                  "type": "Handle|undefined",
                  "desc": "`undefined` or a `net.Socket`, `net.Server`, or `dgram.Socket` object."
                }
              ],
              "desc": "<p>The <code>'message'</code> event is triggered when a child process uses\n<a href=\"process.html#processsendmessage-sendhandle-options-callback\"><code>process.send()</code></a> to send messages.</p>\n<p>The message goes through serialization and parsing. The resulting\nmessage might not be the same as what is originally sent.</p>\n<p>If the <code>serialization</code> option was set to <code>'advanced'</code> used when spawning the\nchild process, the <code>message</code> argument can contain data that JSON is not able\nto represent.\nSee <a href=\"#advanced-serialization\">Advanced serialization</a> for more details.</p>"
            },
            {
              "textRaw": "Event: `'spawn'`",
              "name": "spawn",
              "type": "event",
              "meta": {
                "added": [
                  "v15.1.0",
                  "v14.17.0"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>The <code>'spawn'</code> event is emitted once the child process has spawned successfully.\nIf the child process does not spawn successfully, the <code>'spawn'</code> event is not\nemitted and the <code>'error'</code> event is emitted instead.</p>\n<p>If emitted, the <code>'spawn'</code> event comes before all other events and before any\ndata is received via <code>stdout</code> or <code>stderr</code>.</p>\n<p>The <code>'spawn'</code> event will fire regardless of whether an error occurs <strong>within</strong>\nthe spawned process. For example, if <code>bash some-command</code> spawns successfully,\nthe <code>'spawn'</code> event will fire, though <code>bash</code> may fail to spawn <code>some-command</code>.\nThis caveat also applies when using <code>{ shell: true }</code>.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {Object} A pipe representing the IPC channel to the child process.",
              "name": "channel",
              "type": "Object",
              "meta": {
                "added": [
                  "v7.1.0"
                ],
                "changes": [
                  {
                    "version": "v14.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/30165",
                    "description": "The object no longer accidentally exposes native C++ bindings."
                  }
                ]
              },
              "desc": "<p>The <code>subprocess.channel</code> property is a reference to the child's IPC channel. If\nno IPC channel exists, this property is <code>undefined</code>.</p>",
              "shortDesc": "A pipe representing the IPC channel to the child process.",
              "methods": [
                {
                  "textRaw": "`subprocess.channel.ref()`",
                  "name": "ref",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v7.1.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>This method makes the IPC channel keep the event loop of the parent process\nrunning if <code>.unref()</code> has been called before.</p>"
                },
                {
                  "textRaw": "`subprocess.channel.unref()`",
                  "name": "unref",
                  "type": "method",
                  "meta": {
                    "added": [
                      "v7.1.0"
                    ],
                    "changes": []
                  },
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>This method makes the IPC channel not keep the event loop of the parent process\nrunning, and lets it finish even while the channel is open.</p>"
                }
              ]
            },
            {
              "textRaw": "Type: {boolean} Set to `false` after `subprocess.disconnect()` is called.",
              "name": "connected",
              "type": "boolean",
              "meta": {
                "added": [
                  "v0.7.2"
                ],
                "changes": []
              },
              "desc": "<p>The <code>subprocess.connected</code> property indicates whether it is still possible to\nsend and receive messages from a child process. When <code>subprocess.connected</code> is\n<code>false</code>, it is no longer possible to send or receive messages.</p>",
              "shortDesc": "Set to `false` after `subprocess.disconnect()` is called."
            },
            {
              "textRaw": "Type: {integer}",
              "name": "exitCode",
              "type": "integer",
              "desc": "<p>The <code>subprocess.exitCode</code> property indicates the exit code of the child process.\nIf the child process is still running, the field will be <code>null</code>.</p>\n<p>When the child process is terminated by a signal, <code>subprocess.exitCode</code> will be\n<code>null</code> and <a href=\"#subprocesssignalcode\"><code>subprocess.signalCode</code></a> will be set. To get the corresponding\nPOSIX exit code, use\n<a href=\"util.html#utilconvertprocesssignaltoexitcodesignal\"><code>util.convertProcessSignalToExitCode(subprocess.signalCode)</code></a>.</p>"
            },
            {
              "textRaw": "Type: {boolean} Set to `true` after `subprocess.kill()` is used to successfully send a signal to the child process.",
              "name": "killed",
              "type": "boolean",
              "meta": {
                "added": [
                  "v0.5.10"
                ],
                "changes": []
              },
              "desc": "<p>The <code>subprocess.killed</code> property indicates whether the child process\nsuccessfully received a signal from <code>subprocess.kill()</code>. The <code>killed</code> property\ndoes not indicate that the child process has been terminated.</p>",
              "shortDesc": "Set to `true` after `subprocess.kill()` is used to successfully send a signal to the child process."
            },
            {
              "textRaw": "Type: {integer|undefined}",
              "name": "pid",
              "type": "integer|undefined",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "desc": "<p>Returns the process identifier (PID) of the child process. If the child process\nfails to spawn due to errors, then the value is <code>undefined</code> and <code>error</code> is\nemitted.</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst grep = spawn('grep', ['ssh']);\n\nconsole.log(`Spawned child pid: ${grep.pid}`);\ngrep.stdin.end();\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nconst grep = spawn('grep', ['ssh']);\n\nconsole.log(`Spawned child pid: ${grep.pid}`);\ngrep.stdin.end();\n</code></pre>"
            },
            {
              "textRaw": "Type: {string|null}",
              "name": "signalCode",
              "type": "string|null",
              "desc": "<p>The <code>subprocess.signalCode</code> property indicates the signal received by\nthe child process if any, else <code>null</code>.</p>\n<p>When the child process is terminated by a signal, <a href=\"#subprocessexitcode\"><code>subprocess.exitCode</code></a> will be <code>null</code>.\nTo get the corresponding POSIX exit code, use\n<a href=\"util.html#utilconvertprocesssignaltoexitcodesignal\"><code>util.convertProcessSignalToExitCode(subprocess.signalCode)</code></a>.</p>"
            },
            {
              "textRaw": "Type: {Array}",
              "name": "spawnargs",
              "type": "Array",
              "desc": "<p>The <code>subprocess.spawnargs</code> property represents the full list of command-line\narguments the child process was launched with.</p>"
            },
            {
              "textRaw": "Type: {string}",
              "name": "spawnfile",
              "type": "string",
              "desc": "<p>The <code>subprocess.spawnfile</code> property indicates the executable file name of\nthe child process that is launched.</p>\n<p>For <a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>, its value will be equal to\n<a href=\"process.html#processexecpath\"><code>process.execPath</code></a>.\nFor <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a>, its value will be the name of\nthe executable file.\nFor <a href=\"#child_processexeccommand-options-callback\"><code>child_process.exec()</code></a>,  its value will be the name of the shell\nin which the child process is launched.</p>"
            },
            {
              "textRaw": "Type: {stream.Readable|null|undefined}",
              "name": "stderr",
              "type": "stream.Readable|null|undefined",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "desc": "<p>A <code>Readable Stream</code> that represents the child process's <code>stderr</code>.</p>\n<p>If the child process was spawned with <code>stdio[2]</code> set to anything other than <code>'pipe'</code>,\nthen this will be <code>null</code>.</p>\n<p><code>subprocess.stderr</code> is an alias for <code>subprocess.stdio[2]</code>. Both properties will\nrefer to the same value.</p>\n<p>The <code>subprocess.stderr</code> property can be <code>null</code> or <code>undefined</code>\nif the child process could not be successfully spawned.</p>"
            },
            {
              "textRaw": "Type: {stream.Writable|null|undefined}",
              "name": "stdin",
              "type": "stream.Writable|null|undefined",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "desc": "<p>A <code>Writable Stream</code> that represents the child process's <code>stdin</code>.</p>\n<p>If a child process waits to read all of its input, the child process will not continue\nuntil this stream has been closed via <code>end()</code>.</p>\n<p>If the child process was spawned with <code>stdio[0]</code> set to anything other than <code>'pipe'</code>,\nthen this will be <code>null</code>.</p>\n<p><code>subprocess.stdin</code> is an alias for <code>subprocess.stdio[0]</code>. Both properties will\nrefer to the same value.</p>\n<p>The <code>subprocess.stdin</code> property can be <code>null</code> or <code>undefined</code>\nif the child process could not be successfully spawned.</p>"
            },
            {
              "textRaw": "Type: {Array}",
              "name": "stdio",
              "type": "Array",
              "meta": {
                "added": [
                  "v0.7.10"
                ],
                "changes": []
              },
              "desc": "<p>A sparse array of pipes to the child process, corresponding with positions in\nthe <a href=\"#optionsstdio\"><code>stdio</code></a> option passed to <a href=\"#child_processspawncommand-args-options\"><code>child_process.spawn()</code></a> that have been set\nto the value <code>'pipe'</code>. <code>subprocess.stdio[0]</code>, <code>subprocess.stdio[1]</code>, and\n<code>subprocess.stdio[2]</code> are also available as <code>subprocess.stdin</code>,\n<code>subprocess.stdout</code>, and <code>subprocess.stderr</code>, respectively.</p>\n<p>In the following example, only the child's fd <code>1</code> (stdout) is configured as a\npipe, so only the parent's <code>subprocess.stdio[1]</code> is a stream, all other values\nin the array are <code>null</code>.</p>\n<pre><code class=\"language-cjs\">const assert = require('node:assert');\nconst fs = require('node:fs');\nconst child_process = require('node:child_process');\n\nconst subprocess = child_process.spawn('ls', {\n  stdio: [\n    0, // Use parent's stdin for child.\n    'pipe', // Pipe child's stdout to parent.\n    fs.openSync('err.out', 'w'), // Direct child's stderr to a file.\n  ],\n});\n\nassert.strictEqual(subprocess.stdio[0], null);\nassert.strictEqual(subprocess.stdio[0], subprocess.stdin);\n\nassert(subprocess.stdout);\nassert.strictEqual(subprocess.stdio[1], subprocess.stdout);\n\nassert.strictEqual(subprocess.stdio[2], null);\nassert.strictEqual(subprocess.stdio[2], subprocess.stderr);\n</code></pre>\n<pre><code class=\"language-mjs\">import assert from 'node:assert';\nimport fs from 'node:fs';\nimport child_process from 'node:child_process';\n\nconst subprocess = child_process.spawn('ls', {\n  stdio: [\n    0, // Use parent's stdin for child.\n    'pipe', // Pipe child's stdout to parent.\n    fs.openSync('err.out', 'w'), // Direct child's stderr to a file.\n  ],\n});\n\nassert.strictEqual(subprocess.stdio[0], null);\nassert.strictEqual(subprocess.stdio[0], subprocess.stdin);\n\nassert(subprocess.stdout);\nassert.strictEqual(subprocess.stdio[1], subprocess.stdout);\n\nassert.strictEqual(subprocess.stdio[2], null);\nassert.strictEqual(subprocess.stdio[2], subprocess.stderr);\n</code></pre>\n<p>The <code>subprocess.stdio</code> property can be <code>undefined</code> if the child process could\nnot be successfully spawned.</p>"
            },
            {
              "textRaw": "Type: {stream.Readable|null|undefined}",
              "name": "stdout",
              "type": "stream.Readable|null|undefined",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "desc": "<p>A <code>Readable Stream</code> that represents the child process's <code>stdout</code>.</p>\n<p>If the child process was spawned with <code>stdio[1]</code> set to anything other than <code>'pipe'</code>,\nthen this will be <code>null</code>.</p>\n<p><code>subprocess.stdout</code> is an alias for <code>subprocess.stdio[1]</code>. Both properties will\nrefer to the same value.</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\n\nconst subprocess = spawn('ls');\n\nsubprocess.stdout.on('data', (data) => {\n  console.log(`Received chunk ${data}`);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\n\nconst subprocess = spawn('ls');\n\nsubprocess.stdout.on('data', (data) => {\n  console.log(`Received chunk ${data}`);\n});\n</code></pre>\n<p>The <code>subprocess.stdout</code> property can be <code>null</code> or <code>undefined</code>\nif the child process could not be successfully spawned.</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`subprocess.disconnect()`",
              "name": "disconnect",
              "type": "method",
              "meta": {
                "added": [
                  "v0.7.2"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Closes the IPC channel between parent and child processes, allowing the child\nprocess to exit gracefully once there are no other connections keeping it alive.\nAfter calling this method the <code>subprocess.connected</code> and\n<code>process.connected</code> properties in both the parent and child processes\n(respectively) will be set to <code>false</code>, and it will be no longer possible\nto pass messages between the processes.</p>\n<p>The <code>'disconnect'</code> event will be emitted when there are no messages in the\nprocess of being received. This will most often be triggered immediately after\ncalling <code>subprocess.disconnect()</code>.</p>\n<p>When the child process is a Node.js instance (e.g. spawned using\n<a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>), the <code>process.disconnect()</code> method can be invoked\nwithin the child process to close the IPC channel as well.</p>"
            },
            {
              "textRaw": "`subprocess.kill([signal])`",
              "name": "kill",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.90"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`signal` {number|string}",
                      "name": "signal",
                      "type": "number|string",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>The <code>subprocess.kill()</code> method sends a signal to the child process. If no\nargument is given, the process will be sent the <code>'SIGTERM'</code> signal. See\n<a href=\"http://man7.org/linux/man-pages/man7/signal.7.html\"><code>signal(7)</code></a> for a list of available signals. This function returns <code>true</code> if\n<a href=\"http://man7.org/linux/man-pages/man2/kill.2.html\"><code>kill(2)</code></a> succeeds, and <code>false</code> otherwise.</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\nconst grep = spawn('grep', ['ssh']);\n\ngrep.on('close', (code, signal) => {\n  console.log(\n    `child process terminated due to receipt of signal ${signal}`);\n});\n\n// Send SIGHUP to process.\ngrep.kill('SIGHUP');\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nconst grep = spawn('grep', ['ssh']);\n\ngrep.on('close', (code, signal) => {\n  console.log(\n    `child process terminated due to receipt of signal ${signal}`);\n});\n\n// Send SIGHUP to process.\ngrep.kill('SIGHUP');\n</code></pre>\n<p>The <a href=\"#class-childprocess\"><code>ChildProcess</code></a> object may emit an <a href=\"#event-error\"><code>'error'</code></a> event if the signal\ncannot be delivered. Sending a signal to a child process that has already exited\nis not an error but may have unforeseen consequences. Specifically, if the\nprocess identifier (PID) has been reassigned to another process, the signal will\nbe delivered to that process instead which can have unexpected results.</p>\n<p>While the function is called <code>kill</code>, the signal delivered to the child process\nmay not actually terminate the process.</p>\n<p>See <a href=\"http://man7.org/linux/man-pages/man2/kill.2.html\"><code>kill(2)</code></a> for reference.</p>\n<p>On Windows, where POSIX signals do not exist, signals are handled as follows.\n<code>'SIGKILL'</code>, <code>'SIGTERM'</code>, <code>'SIGINT'</code> and <code>'SIGQUIT'</code> terminate the process\nforcefully and abruptly (similar to <code>'SIGKILL'</code>); any other signal whose name is\nknown on Windows (such as <code>'SIGHUP'</code>) does the same. <code>'SIGWINCH'</code> is not\nterminal and is not coerced: <code>subprocess.kill()</code> throws an <code>ENOSYS</code> error and\nthe child keeps running. A signal name that does not exist on Windows (such as\n<code>'SIGSTOP'</code>) throws an <code>ERR_UNKNOWN_SIGNAL</code> error. See <a href=\"process.html#signal-events\">Signal Events</a> for more\ndetails.</p>\n<p>On Linux, child processes of child processes will not be terminated\nwhen attempting to kill their parent. This is likely to happen when running a\nnew process in a shell or with the use of the <code>shell</code> option of <code>ChildProcess</code>:</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\n\nconst subprocess = spawn(\n  'sh',\n  [\n    '-c',\n    `node -e \"setInterval(() => {\n      console.log(process.pid, 'is alive')\n    }, 500);\"`,\n  ], {\n    stdio: ['inherit', 'inherit', 'inherit'],\n  },\n);\n\nsetTimeout(() => {\n  subprocess.kill(); // Does not terminate the Node.js process in the shell.\n}, 2000);\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\n\nconst subprocess = spawn(\n  'sh',\n  [\n    '-c',\n    `node -e \"setInterval(() => {\n      console.log(process.pid, 'is alive')\n    }, 500);\"`,\n  ], {\n    stdio: ['inherit', 'inherit', 'inherit'],\n  },\n);\n\nsetTimeout(() => {\n  subprocess.kill(); // Does not terminate the Node.js process in the shell.\n}, 2000);\n</code></pre>"
            },
            {
              "textRaw": "`subprocess[Symbol.dispose]()`",
              "name": "[Symbol.dispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v20.5.0",
                  "v18.18.0"
                ],
                "changes": [
                  {
                    "version": "v24.2.0",
                    "pr-url": "https://github.com/nodejs/node/pull/58467",
                    "description": "No longer experimental."
                  }
                ]
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Calls <a href=\"#subprocesskillsignal\"><code>subprocess.kill()</code></a> with <code>'SIGTERM'</code>.</p>"
            },
            {
              "textRaw": "`subprocess.ref()`",
              "name": "ref",
              "type": "method",
              "meta": {
                "added": [
                  "v0.7.10"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Calling <code>subprocess.ref()</code> after making a call to <code>subprocess.unref()</code> will\nrestore the removed reference count for the child process, forcing the parent\nprocess to wait for the child process to exit before exiting itself.</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\n\nconst subprocess = spawn(process.argv[0], ['child_program.js'], {\n  detached: true,\n  stdio: 'ignore',\n});\n\nsubprocess.unref();\nsubprocess.ref();\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport process from 'node:process';\n\nconst subprocess = spawn(process.argv[0], ['child_program.js'], {\n  detached: true,\n  stdio: 'ignore',\n});\n\nsubprocess.unref();\nsubprocess.ref();\n</code></pre>"
            },
            {
              "textRaw": "`subprocess.send(message[, sendHandle[, options]][, callback])`",
              "name": "send",
              "type": "method",
              "meta": {
                "added": [
                  "v0.5.9"
                ],
                "changes": [
                  {
                    "version": "v5.8.0",
                    "pr-url": "https://github.com/nodejs/node/pull/5283",
                    "description": "The `options` parameter, and the `keepOpen` option in particular, is supported now."
                  },
                  {
                    "version": "v5.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/3516",
                    "description": "This method returns a boolean for flow control now."
                  },
                  {
                    "version": "v4.0.0",
                    "pr-url": "https://github.com/nodejs/node/pull/2620",
                    "description": "The `callback` parameter is supported now."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`message` {Object}",
                      "name": "message",
                      "type": "Object"
                    },
                    {
                      "textRaw": "`sendHandle` {Handle|undefined} `undefined`, or a `net.Socket`, `net.Server`, or `dgram.Socket` object.",
                      "name": "sendHandle",
                      "type": "Handle|undefined",
                      "desc": "`undefined`, or a `net.Socket`, `net.Server`, or `dgram.Socket` object.",
                      "optional": true
                    },
                    {
                      "textRaw": "`options` {Object} The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:",
                      "name": "options",
                      "type": "Object",
                      "desc": "The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:",
                      "options": [
                        {
                          "textRaw": "`keepOpen` {boolean} A value that can be used when passing instances of `net.Socket`. When `true`, the socket is kept open in the sending process. **Default:** `false`.",
                          "name": "keepOpen",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "A value that can be used when passing instances of `net.Socket`. When `true`, the socket is kept open in the sending process."
                        }
                      ],
                      "optional": true
                    },
                    {
                      "textRaw": "`callback` {Function}",
                      "name": "callback",
                      "type": "Function",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>When an IPC channel has been established between the parent and child processes\n( i.e. when using <a href=\"#child_processforkmodulepath-args-options\"><code>child_process.fork()</code></a>), the <code>subprocess.send()</code> method\ncan be used to send messages to the child process. When the child process is a\nNode.js instance, these messages can be received via the <a href=\"process.html#event-message\"><code>'message'</code></a> event.</p>\n<p>The message goes through serialization and parsing. The resulting\nmessage might not be the same as what is originally sent.</p>\n<p>For example, in the parent script:</p>\n<pre><code class=\"language-cjs\">const { fork } = require('node:child_process');\nconst forkedProcess = fork(`${__dirname}/sub.js`);\n\nforkedProcess.on('message', (message) => {\n  console.log('PARENT got message:', message);\n});\n\n// Causes the child to print: CHILD got message: { hello: 'world' }\nforkedProcess.send({ hello: 'world' });\n</code></pre>\n<pre><code class=\"language-mjs\">import { fork } from 'node:child_process';\nconst forkedProcess = fork(`${import.meta.dirname}/sub.js`);\n\nforkedProcess.on('message', (message) => {\n  console.log('PARENT got message:', message);\n});\n\n// Causes the child to print: CHILD got message: { hello: 'world' }\nforkedProcess.send({ hello: 'world' });\n</code></pre>\n<p>And then the child script, <code>'sub.js'</code> might look like this:</p>\n<pre><code class=\"language-js\">process.on('message', (message) => {\n  console.log('CHILD got message:', message);\n});\n\n// Causes the parent to print: PARENT got message: { foo: 'bar', baz: null }\nprocess.send({ foo: 'bar', baz: NaN });\n</code></pre>\n<p>Child Node.js processes will have a <a href=\"process.html#processsendmessage-sendhandle-options-callback\"><code>process.send()</code></a> method of their own\nthat allows the child process to send messages back to the parent process.</p>\n<p>There is a special case when sending a <code>{cmd: 'NODE_foo'}</code> message. Messages\ncontaining a <code>NODE_</code> prefix in the <code>cmd</code> property are reserved for use within\nNode.js core and will not be emitted in the child's <a href=\"process.html#event-message\"><code>'message'</code></a>\nevent. Rather, such messages are emitted using the\n<code>'internalMessage'</code> event and are consumed internally by Node.js.\nApplications should avoid using such messages or listening for\n<code>'internalMessage'</code> events as it is subject to change without notice.</p>\n<p>The optional <code>sendHandle</code> argument that may be passed to <code>subprocess.send()</code> is\nfor passing a TCP server or socket object to the child process. The child process will\nreceive the object as the second argument passed to the callback function\nregistered on the <a href=\"process.html#event-message\"><code>'message'</code></a> event. Any data that is received\nand buffered in the socket will not be sent to the child. Sending IPC sockets is\nnot supported on Windows.</p>\n<p>The optional <code>callback</code> is a function that is invoked after the message is\nsent but before the child process may have received it. The function is called with a\nsingle argument: <code>null</code> on success, or an <a href=\"errors.html#class-error\"><code>Error</code></a> object on failure.</p>\n<p>If no <code>callback</code> function is provided and the message cannot be sent, an\n<code>'error'</code> event will be emitted by the <a href=\"#class-childprocess\"><code>ChildProcess</code></a> object. This can\nhappen, for instance, when the child process has already exited.</p>\n<p><code>subprocess.send()</code> will return <code>false</code> if the channel has closed or when the\nbacklog of unsent messages exceeds a threshold that makes it unwise to send\nmore. Otherwise, the method returns <code>true</code>. The <code>callback</code> function can be\nused to implement flow control.</p>",
              "modules": [
                {
                  "textRaw": "Example: sending a server object",
                  "name": "example:_sending_a_server_object",
                  "type": "module",
                  "desc": "<p>The <code>sendHandle</code> argument can be used, for instance, to pass the handle of\na TCP server object to the child process as illustrated in the example below:</p>\n<pre><code class=\"language-cjs\">const { fork } = require('node:child_process');\nconst { createServer } = require('node:net');\n\nconst subprocess = fork('subprocess.js');\n\n// Open up the server object and send the handle.\nconst server = createServer();\nserver.on('connection', (socket) => {\n  socket.end('handled by parent');\n});\nserver.listen(1337, () => {\n  subprocess.send('server', server);\n});\n</code></pre>\n<pre><code class=\"language-mjs\">import { fork } from 'node:child_process';\nimport { createServer } from 'node:net';\n\nconst subprocess = fork('subprocess.js');\n\n// Open up the server object and send the handle.\nconst server = createServer();\nserver.on('connection', (socket) => {\n  socket.end('handled by parent');\n});\nserver.listen(1337, () => {\n  subprocess.send('server', server);\n});\n</code></pre>\n<p>The child process would then receive the server object as:</p>\n<pre><code class=\"language-js\">process.on('message', (m, server) => {\n  if (m === 'server') {\n    server.on('connection', (socket) => {\n      socket.end('handled by child');\n    });\n  }\n});\n</code></pre>\n<p>Once the server is now shared between the parent and child, some connections\ncan be handled by the parent and some by the child.</p>\n<p>While the example above uses a server created using the <code>node:net</code> module,\n<code>node:dgram</code> module servers use exactly the same workflow with the exceptions of\nlistening on a <code>'message'</code> event instead of <code>'connection'</code> and using\n<code>server.bind()</code> instead of <code>server.listen()</code>. This is, however, only\nsupported on Unix platforms.</p>",
                  "displayName": "Example: sending a server object"
                },
                {
                  "textRaw": "Example: sending a socket object",
                  "name": "example:_sending_a_socket_object",
                  "type": "module",
                  "desc": "<p>Similarly, the <code>sendHandler</code> argument can be used to pass the handle of a\nsocket to the child process. The example below spawns two children that each\nhandle connections with \"normal\" or \"special\" priority:</p>\n<pre><code class=\"language-cjs\">const { fork } = require('node:child_process');\nconst { createServer } = require('node:net');\n\nconst normal = fork('subprocess.js', ['normal']);\nconst special = fork('subprocess.js', ['special']);\n\n// Open up the server and send sockets to child. Use pauseOnConnect to prevent\n// the sockets from being read before they are sent to the child process.\nconst server = createServer({ pauseOnConnect: true });\nserver.on('connection', (socket) => {\n\n  // If this is special priority...\n  if (socket.remoteAddress === '74.125.127.100') {\n    special.send('socket', socket);\n    return;\n  }\n  // This is normal priority.\n  normal.send('socket', socket);\n});\nserver.listen(1337);\n</code></pre>\n<pre><code class=\"language-mjs\">import { fork } from 'node:child_process';\nimport { createServer } from 'node:net';\n\nconst normal = fork('subprocess.js', ['normal']);\nconst special = fork('subprocess.js', ['special']);\n\n// Open up the server and send sockets to child. Use pauseOnConnect to prevent\n// the sockets from being read before they are sent to the child process.\nconst server = createServer({ pauseOnConnect: true });\nserver.on('connection', (socket) => {\n\n  // If this is special priority...\n  if (socket.remoteAddress === '74.125.127.100') {\n    special.send('socket', socket);\n    return;\n  }\n  // This is normal priority.\n  normal.send('socket', socket);\n});\nserver.listen(1337);\n</code></pre>\n<p>The <code>subprocess.js</code> would receive the socket handle as the second argument\npassed to the event callback function:</p>\n<pre><code class=\"language-js\">process.on('message', (m, socket) => {\n  if (m === 'socket') {\n    if (socket) {\n      // Check that the client socket exists.\n      // It is possible for the socket to be closed between the time it is\n      // sent and the time it is received in the child process.\n      socket.end(`Request handled with ${process.argv[2]} priority`);\n    }\n  }\n});\n</code></pre>\n<p>Do not use <code>.maxConnections</code> on a socket that has been passed to a subprocess.\nThe parent cannot track when the socket is destroyed.</p>\n<p>Any <code>'message'</code> handlers in the subprocess should verify that <code>socket</code> exists,\nas the connection may have been closed during the time it takes to send the\nconnection to the child.</p>",
                  "displayName": "Example: sending a socket object"
                }
              ]
            },
            {
              "textRaw": "`subprocess.unref()`",
              "name": "unref",
              "type": "method",
              "meta": {
                "added": [
                  "v0.7.10"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>By default, the parent process will wait for the detached child process to exit.\nTo prevent the parent process from waiting for a given <code>subprocess</code> to exit, use the\n<code>subprocess.unref()</code> method. Doing so will cause the parent's event loop to not\ninclude the child process in its reference count, allowing the parent to exit\nindependently of the child, unless there is an established IPC channel between\nthe child and the parent processes.</p>\n<pre><code class=\"language-cjs\">const { spawn } = require('node:child_process');\n\nconst subprocess = spawn(process.argv[0], ['child_program.js'], {\n  detached: true,\n  stdio: 'ignore',\n});\n\nsubprocess.unref();\n</code></pre>\n<pre><code class=\"language-mjs\">import { spawn } from 'node:child_process';\nimport process from 'node:process';\n\nconst subprocess = spawn(process.argv[0], ['child_program.js'], {\n  detached: true,\n  stdio: 'ignore',\n});\n\nsubprocess.unref();\n</code></pre>"
            }
          ]
        }
      ],
      "displayName": "Child process"
    }
  ]
}