Skip to content

Instantly share code, notes, and snippets.

@tjfontaine
Created November 19, 2013 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjfontaine/7553906 to your computer and use it in GitHub Desktop.
Save tjfontaine/7553906 to your computer and use it in GitHub Desktop.
diff --git a/lib/child_process.js b/lib/child_process.js
index 33928a9..151897d 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -952,7 +952,10 @@ ChildProcess.prototype.spawn = function(options) {
var err = this._handle.spawn(options);
- if (err) {
+ if (!constants)
+ constants = process.binding('constants');
+
+ if (err && (err * -1) != constants.ENOENT) {
// Close all opened fds on error
stdio.forEach(function(stdio) {
if (stdio.type === 'pipe') {
@@ -965,6 +968,12 @@ ChildProcess.prototype.spawn = function(options) {
throw errnoException(err, 'spawn');
}
+ if (err) {
+ process.nextTick(function() {
+ self._handle.onexit(err);
+ });
+ }
+
this.pid = this._handle.pid;
stdio.forEach(function(stdio, i) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment