Skip to content

Commit 5d1710e

Browse files
committed
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: nodejs#2721
1 parent cdfa271 commit 5d1710e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/child_process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ function _validateStdio(stdio, sync) {
766766
} else if (typeof stdio === 'number' || typeof stdio.fd === 'number') {
767767
acc.push({
768768
type: 'fd',
769-
fd: stdio.fd || stdio
769+
fd: typeof stdio === 'number' ? stdio : stdio.fd
770770
});
771771
} else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) ||
772772
getHandleWrapType(stdio._handle)) {

0 commit comments

Comments
 (0)