mirror of https://github.com/nodejs/node.git
Don't emit 'exit' twice from child process
parent
d7762dffe3
commit
d38d96eb61
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue