diff --git a/doc/api/child_process.md b/doc/api/child_process.md index ae4806382bb8ff..7f5c4f8db187b4 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1196,7 +1196,8 @@ changes: `'/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). -* Returns: {Buffer|string} The stdout from the command. +* Returns: {Buffer|string|null} If `stdio` is `'pipe'`, the stdout from the + command, otherwise null. The `child_process.execFileSync()` method is generally identical to [`child_process.execFile()`][] with the exception that the method will not @@ -1323,7 +1324,8 @@ changes: **Default:** `'buffer'`. * `windowsHide` {boolean} Hide the subprocess console window that would normally be created on Windows systems. **Default:** `false`. -* Returns: {Buffer|string} The stdout from the command. +* Returns: {Buffer|string|null} If `stdio` is `'pipe'`, the stdout from the + command, otherwise null. The `child_process.execSync()` method is generally identical to [`child_process.exec()`][] with the exception that the method will not return @@ -1407,8 +1409,10 @@ changes: * Returns: {Object} * `pid` {number} Pid of the child process. * `output` {Array} Array of results from stdio output. - * `stdout` {Buffer|string} The contents of `output[1]`. - * `stderr` {Buffer|string} The contents of `output[2]`. + * `stdout` {Buffer|string|null} If `stdio` is `'pipe'`, the contents of + `output[1]`, otherwise null. + * `stderr` {Buffer|string|null} If `stdio` is `'pipe'`, the contents of + `output[2]`, otherwise null. * `status` {number|null} The exit code of the subprocess, or `null` if the subprocess terminated due to a signal. * `signal` {string|null} The signal used to kill the subprocess, or `null` if diff --git a/lib/child_process.js b/lib/child_process.js index 21616c69f877ec..dfeed772e0d760 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -823,8 +823,8 @@ function spawn(file, args, options) { * @returns {{ * pid: number; * output: Array; - * stdout: Buffer | string; - * stderr: Buffer | string; + * stdout: Buffer | string | null; + * stderr: Buffer | string | null; * status: number | null; * signal: string | null; * error: Error; @@ -912,7 +912,7 @@ function checkExecSyncError(ret, args, cmd) { * windowsHide?: boolean; * shell?: boolean | string; * }} [options] - * @returns {Buffer | string} + * @returns {Buffer | string | null} */ function execFileSync(file, args, options) { ({ file, args, options } = normalizeExecFileArgs(file, args, options)); @@ -950,7 +950,7 @@ function execFileSync(file, args, options) { * encoding?: string; * windowsHide?: boolean; * }} [options] - * @returns {Buffer | string} + * @returns {Buffer | string | null} */ function execSync(command, options) { const opts = normalizeExecArgs(command, options, null);