ChildProcesses cannot be killed if pid is missing
This commit is contained in:
parent
78da9cb052
commit
5a98fa4809
@ -63,14 +63,7 @@ exports.execFile = function (file /* args, options, callback */) {
|
|||||||
var killed = false;
|
var killed = false;
|
||||||
|
|
||||||
function kill () {
|
function kill () {
|
||||||
if (killed) return;
|
|
||||||
try {
|
|
||||||
child.kill(options.killSignal);
|
child.kill(options.killSignal);
|
||||||
} catch (err) {
|
|
||||||
if ("No such process" !== err.message) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
killed = true;
|
killed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,10 +160,12 @@ util.inherits(ChildProcess, EventEmitter);
|
|||||||
|
|
||||||
|
|
||||||
ChildProcess.prototype.kill = function (sig) {
|
ChildProcess.prototype.kill = function (sig) {
|
||||||
|
if (this._internal.pid) {
|
||||||
if (!constants) constants = process.binding("constants");
|
if (!constants) constants = process.binding("constants");
|
||||||
sig = sig || 'SIGTERM';
|
sig = sig || 'SIGTERM';
|
||||||
if (!constants[sig]) throw new Error("Unknown signal: " + sig);
|
if (!constants[sig]) throw new Error("Unknown signal: " + sig);
|
||||||
return this._internal.kill(constants[sig]);
|
return this._internal.kill(constants[sig]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user