|
|
@ -99,14 +99,22 @@ function ChildProcess () { |
|
|
|
var stdout = this.stdout = new Stream(); |
|
|
|
var stderr = this.stderr = new Stream(); |
|
|
|
|
|
|
|
function onClose () { |
|
|
|
if (gotCHLD && !stdout.readable && !stderr.readable) { |
|
|
|
var stderrClosed = false; |
|
|
|
var stdoutClosed = false; |
|
|
|
|
|
|
|
stderr.addListener('close', function () { |
|
|
|
stderrClosed = true; |
|
|
|
if (gotCHLD && stdoutClosed) { |
|
|
|
self.emit('exit', exitCode, termSignal); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
stderr.addListener('close', onClose); |
|
|
|
stdout.addListener('close', onClose); |
|
|
|
stdout.addListener('close', function () { |
|
|
|
stdoutClosed = true; |
|
|
|
if (gotCHLD && stderrClosed) { |
|
|
|
self.emit('exit', exitCode, termSignal); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
internal.onexit = function (code, signal) { |
|
|
|
gotCHLD = true; |
|
|
|