|
@ -60,6 +60,8 @@ exports.execFile = function(file /* args, options, callback */) { |
|
|
var exited = false; |
|
|
var exited = false; |
|
|
var timeoutId; |
|
|
var timeoutId; |
|
|
|
|
|
|
|
|
|
|
|
var err; |
|
|
|
|
|
|
|
|
function exithandler(code, signal) { |
|
|
function exithandler(code, signal) { |
|
|
if (exited) return; |
|
|
if (exited) return; |
|
|
exited = true; |
|
|
exited = true; |
|
@ -71,7 +73,9 @@ exports.execFile = function(file /* args, options, callback */) { |
|
|
|
|
|
|
|
|
if (!callback) return; |
|
|
if (!callback) return; |
|
|
|
|
|
|
|
|
if (code === 0 && signal === null) { |
|
|
if (err) { |
|
|
|
|
|
callback(err, stdout, stderr); |
|
|
|
|
|
} else if (code === 0 && signal === null) { |
|
|
callback(null, stdout, stderr); |
|
|
callback(null, stdout, stderr); |
|
|
} else { |
|
|
} else { |
|
|
var e = new Error('Command failed: ' + stderr); |
|
|
var e = new Error('Command failed: ' + stderr); |
|
@ -103,6 +107,7 @@ exports.execFile = function(file /* args, options, callback */) { |
|
|
child.stdout.addListener('data', function(chunk) { |
|
|
child.stdout.addListener('data', function(chunk) { |
|
|
stdout += chunk; |
|
|
stdout += chunk; |
|
|
if (stdout.length > options.maxBuffer) { |
|
|
if (stdout.length > options.maxBuffer) { |
|
|
|
|
|
err = new Error('maxBuffer exceeded.'); |
|
|
kill(); |
|
|
kill(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -110,6 +115,7 @@ exports.execFile = function(file /* args, options, callback */) { |
|
|
child.stderr.addListener('data', function(chunk) { |
|
|
child.stderr.addListener('data', function(chunk) { |
|
|
stderr += chunk; |
|
|
stderr += chunk; |
|
|
if (stderr.length > options.maxBuffer) { |
|
|
if (stderr.length > options.maxBuffer) { |
|
|
|
|
|
err = new Error('maxBuffer exceeded.'); |
|
|
kill(); |
|
|
kill(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|