From 5d1710e46f4e1865f83d011f02cf32c718fd31f0 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 7 Sep 2015 13:45:43 -0700 Subject: [PATCH] child_process: handle zero fd in process.stdin When passing `process.stdin` in `stdio` options to `child_process.spawn`, make sure that its `fd` is getting passed properly to the C++ internals. It is `0`, so the `stdio.fd || stdio` check will return `process.stdin`, instead of the number. Fix: https://github.com/nodejs/node/issues/2721 --- lib/internal/child_process.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 6d1c22d03b48ee..328a67d1ef0962 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)) {