From 5a98fa4809457f843aae5447ce82b660c8b595f3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 20 Oct 2010 17:55:25 -0700 Subject: [PATCH] ChildProcesses cannot be killed if pid is missing --- lib/child_process.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index b21898d..78d9a96 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -62,15 +62,8 @@ exports.execFile = function (file /* args, options, callback */) { var stderr = ""; var killed = false; - function kill(){ - if (killed) return; - try { - child.kill(options.killSignal); - } catch (err) { - if ("No such process" !== err.message) { - throw err; - } - } + function kill () { + child.kill(options.killSignal); killed = true; } @@ -167,10 +160,12 @@ util.inherits(ChildProcess, EventEmitter); ChildProcess.prototype.kill = function (sig) { - if (!constants) constants = process.binding("constants"); - sig = sig || 'SIGTERM'; - if (!constants[sig]) throw new Error("Unknown signal: " + sig); - return this._internal.kill(constants[sig]); + if (this._internal.pid) { + if (!constants) constants = process.binding("constants"); + sig = sig || 'SIGTERM'; + if (!constants[sig]) throw new Error("Unknown signal: " + sig); + return this._internal.kill(constants[sig]); + } }; -- 2.7.4