diff --git a/lib/monitor/run.js b/lib/monitor/run.js index b98251b5..f9b07d2a 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -262,6 +262,13 @@ function kill(child, signal, callback) { exec('taskkill /pid ' + child.pid + ' /T /F'); callback(); } else { + var stripPrefix = function (signal) { + if (0 === signal.indexOf('SIG')) { + return signal.toString().replace('SIG', ''); + } + + return signal; + }; if (hasPS) { // we use psTree to kill the full subtree of nodemon, because when // spawning processes like `coffee` under the `--debug` flag, it'll spawn @@ -269,12 +276,19 @@ function kill(child, signal, callback) { // an array of PIDs that have spawned under nodemon, and we send each the // configured signal (defaul: SIGUSR2) signal, which fixes #335 psTree(child.pid, function (err, kids) { - spawn('kill', ['-s', signal, child.pid].concat(kids.map(function (p) { - return p.PID; - }))).on('close', callback); + spawn( + 'kill', + ['-s', stripPrefix(signal), child.pid].concat( + kids.map( + function (p) { + return p.PID; + } + ) + ) + ).on('close', callback); }); } else { - exec('kill -s ' + signal + ' ' + child.pid, function () { + exec('kill -s ' + stripPrefix(signal) + ' ' + child.pid, function () { // ignore if the process has been killed already callback(); });