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