|
|
@ -191,6 +191,7 @@ var spawn = exports.spawn = function(file, args, options) { |
|
|
|
|
|
|
|
|
|
|
|
function maybeExit(subprocess) { |
|
|
|
console.log("maybeExit"); |
|
|
|
subprocess._closesGot++; |
|
|
|
|
|
|
|
if (subprocess._closesGot == subprocess._closesNeeded) { |
|
|
@ -213,6 +214,8 @@ function ChildProcess() { |
|
|
|
if (signalCode) self.signalCode = signalCode; |
|
|
|
self.exitCode = exitCode; |
|
|
|
|
|
|
|
console.error("onexit ", exitCode, signalCode); |
|
|
|
|
|
|
|
if (self.stdin) { |
|
|
|
self.stdin.destroy(); |
|
|
|
} |
|
|
@ -250,8 +253,28 @@ ChildProcess.prototype.spawn = function(options) { |
|
|
|
|
|
|
|
var r = this._internal.spawn(options); |
|
|
|
|
|
|
|
if (r) { |
|
|
|
if (options.stdinStream) { |
|
|
|
options.stdinStream.close(); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.stdoutStream) { |
|
|
|
options.stdoutStream.close(); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.stderrStream) { |
|
|
|
options.stderrStream.close(); |
|
|
|
} |
|
|
|
|
|
|
|
this._internal.close(); |
|
|
|
this._internal = null; |
|
|
|
throw errnoException("spawn", errno) |
|
|
|
} |
|
|
|
|
|
|
|
this.pid = this._internal.pid; |
|
|
|
|
|
|
|
console.log("started pid ", this.pid); |
|
|
|
|
|
|
|
if (options.stdinStream) { |
|
|
|
this.stdin = createSocket(options.stdinStream, false); |
|
|
|
} |
|
|
@ -275,6 +298,16 @@ ChildProcess.prototype.spawn = function(options) { |
|
|
|
return r; |
|
|
|
}; |
|
|
|
|
|
|
|
function errnoException(errorno, syscall) { |
|
|
|
// TODO make this more compatible with ErrnoException from src/node.cc
|
|
|
|
// Once all of Node is using this function the ErrnoException from
|
|
|
|
// src/node.cc should be removed.
|
|
|
|
var e = new Error(syscall + ' ' + errorno); |
|
|
|
e.errno = e.code = errorno; |
|
|
|
e.syscall = syscall; |
|
|
|
return e; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ChildProcess.prototype.kill = function(sig) { |
|
|
|
throw new Error("implement me"); |
|
|
|