Skip to content

Commit

Permalink
Add NODE_DEBUG info to child_process
Browse files Browse the repository at this point in the history
Fixes GH-720. Also adds the arguments passed to the Error object.
  • Loading branch information
remixz committed Feb 5, 2015
1 parent e0730ee commit f7711fe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const net = require('net');
const dgram = require('dgram');
const assert = require('assert');
const util = require('util');
const debug = util.debuglog('child_process');

const Process = process.binding('process_wrap').Process;
const WriteWrap = process.binding('stream_wrap').WriteWrap;
Expand Down Expand Up @@ -958,6 +959,8 @@ var spawn = exports.spawn = function(/*file, args, options*/) {
var options = opts.options;
var child = new ChildProcess();

debug('spawn', opts.args, options);

child.spawn({
file: opts.file,
args: opts.args,
Expand Down Expand Up @@ -1035,6 +1038,7 @@ function ChildProcess() {
if (self.spawnfile)
err.path = self.spawnfile;

err.spawnargs = self.spawnargs.slice(1);
self.emit('error', err);
} else {
self.emit('exit', self.exitCode, self.signalCode);
Expand Down Expand Up @@ -1097,6 +1101,7 @@ ChildProcess.prototype.spawn = function(options) {
}

this.spawnfile = options.file;
this.spawnargs = options.args;

var err = this._handle.spawn(options);

Expand Down Expand Up @@ -1246,6 +1251,8 @@ function spawnSync(/*file, args, options*/) {
options.args = opts.args;
options.envPairs = opts.envPairs;

debug('spawnSync', opts.args, options);

if (options.killSignal)
options.killSignal = lookupSignal(options.killSignal);

Expand Down Expand Up @@ -1289,8 +1296,11 @@ function spawnSync(/*file, args, options*/) {
result.stdout = result.output && result.output[1];
result.stderr = result.output && result.output[2];

if (result.error)
result.error = errnoException(result.error, 'spawnSync');
if (result.error) {
result.error = errnoException(result.error, 'spawnSync ' + opts.file);
result.error.path = opts.file;
result.error.spawnargs = opts.args.slice(1);
}

util._extend(result, opts);

Expand Down

0 comments on commit f7711fe

Please sign in to comment.