diff --git a/lib/child_process.js b/lib/child_process.js index 4a9922e53e..a4a5d2b3a9 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -884,9 +884,9 @@ ChildProcess.prototype.spawn = function(options) { if (stdio.handle) { // when i === 0 - we're dealing with stdin // (which is the only one writable pipe) - stdio.socket = createSocket(stdio.handle, i > 0); + stdio.socket = createSocket(self.pid !== 0 ? stdio.handle : null, i > 0); - if (i > 0) { + if (i > 0 && self.pid !== 0) { self._closesNeeded++; stdio.socket.on('close', function() { maybeClose(self);