Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
child process: fix processes with IPC channel don't emit 'close'
Browse files Browse the repository at this point in the history
With this patch the stdio channel is no longer available in the
ChildProcess.stdio array.
  • Loading branch information
piscisaureus committed Aug 30, 2012
1 parent 355c148 commit 191b4d4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/child_process.js
Expand Up @@ -303,6 +303,10 @@ function setupChannel(target, channel) {
}
};

channel.onclose = function() {
maybeClose(target);
};

// object where socket lists will live
channel.sockets = { got: {}, send: {} };

Expand Down Expand Up @@ -745,7 +749,7 @@ ChildProcess.prototype.spawn = function(options) {
ipc = createPipe(true);
ipcFd = i;

acc.push({ type: 'pipe', handle: ipc });
acc.push({ type: 'pipe', handle: ipc, ipc: true });
} else if (typeof stdio === 'number' || typeof stdio.fd === 'number') {
acc.push({ type: 'fd', fd: stdio.fd || stdio });
} else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) ||
Expand Down Expand Up @@ -796,6 +800,11 @@ ChildProcess.prototype.spawn = function(options) {
stdio.forEach(function(stdio, i) {
if (stdio.type === 'ignore') return;

if (stdio.ipc) {
self._closesNeeded++;
return;
}

if (stdio.handle) {
// when i === 0 - we're dealing with stdin
// (which is the only one writable pipe)
Expand Down

0 comments on commit 191b4d4

Please sign in to comment.