From 4aa39ba95e1501c596ba1ed8756ef4581b17a1ee Mon Sep 17 00:00:00 2001 From: knight Date: Wed, 28 Dec 2016 16:10:30 +0100 Subject: [PATCH 1/3] fix: stripping the SIG prefix for POSIX compliance --- lib/monitor/run.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/monitor/run.js b/lib/monitor/run.js index b98251b5..87a788e8 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,12 @@ 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) { + 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(); }); From 43e3bf18a2b70953947e3dbf55c3de89a2f7503e Mon Sep 17 00:00:00 2001 From: knight Date: Thu, 29 Dec 2016 12:04:27 +0100 Subject: [PATCH 2/3] constraint 80 chars --- lib/monitor/run.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/monitor/run.js b/lib/monitor/run.js index 87a788e8..696a74e4 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -276,9 +276,16 @@ 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', stripPrefix(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 ' + stripPrefix(signal) + ' ' + child.pid, function () { From c714eeca380c2f393ffb8a31ab54a9d1db0e9422 Mon Sep 17 00:00:00 2001 From: knight Date: Thu, 29 Dec 2016 12:19:11 +0100 Subject: [PATCH 3/3] linting error --- lib/monitor/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/monitor/run.js b/lib/monitor/run.js index 696a74e4..f9b07d2a 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -280,7 +280,7 @@ function kill(child, signal, callback) { 'kill', ['-s', stripPrefix(signal), child.pid].concat( kids.map( - function(p) { + function (p) { return p.PID; } )