Browse Source

Don't emit 'exit' twice from child process

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
d38d96eb61
  1. 18
      lib/child_process.js

18
lib/child_process.js

@ -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;

Loading…
Cancel
Save