diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 6d1c22d03b..328a67d1ef 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -766,7 +766,7 @@ function _validateStdio(stdio, sync) { } else if (typeof stdio === 'number' || typeof stdio.fd === 'number') { acc.push({ type: 'fd', - fd: stdio.fd || stdio + fd: typeof stdio === 'number' ? stdio : stdio.fd }); } else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) || getHandleWrapType(stdio._handle)) { diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js index aba43551e8..289323002d 100644 --- a/test/parallel/test-child-process-validate-stdio.js +++ b/test/parallel/test-child-process-validate-stdio.js @@ -28,3 +28,15 @@ var stdio2 = ['ipc', 'ipc', 'ipc']; assert.throws(function() { _validateStdio(stdio2, true); }, /You cannot use IPC with synchronous forks/); + +const stdio3 = [process.stdin, process.stdout, process.stderr]; +var result = _validateStdio(stdio3, false); +assert.deepStrictEqual(result, { + stdio: [ + { type: 'fd', fd: 0 }, + { type: 'fd', fd: 1 }, + { type: 'fd', fd: 2 } + ], + ipc: undefined, + ipcFd: undefined +});