diff --git a/lib/monitor/run.js b/lib/monitor/run.js index 9815af49..6dc37f94 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -290,15 +290,21 @@ function kill(child, signal, callback) { // an array of PIDs that have spawned under nodemon, and we send each the // configured signal (default: SIGUSR2) signal, which fixes #335 // note that psTree also works if `ps` is missing by looking in /proc + const sig = signal.replace('SIG', ''); psTree(child.pid, function (err, kids) { - // make sure we kill from smallest to largest - const pids = kids.map(p => p.PID).concat(child.pid).sort(); - - pids.forEach(pid => { - exec('kill -' + signals[signal] + ' ' + pid, () => {}); - }); - callback(); + if (psTree.hasPS) { + spawn('kill', ['-s', sig, child.pid].concat(kids.map(p => p.PID))) + .on('close', callback); + } else { + // make sure we kill from smallest to largest + const pids = kids.map(p => p.PID).concat(child.pid).sort(); + pids.forEach(pid => { + exec('kill -' + signals[signal] + ' ' + pid, () => { }); + }); + callback(); + } }); + } } diff --git a/package-lock.json b/package-lock.json index 4ba07d36..d6baeba0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,9 +48,9 @@ } }, "@remy/pstree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@remy/pstree/-/pstree-1.0.1.tgz", - "integrity": "sha1-Qgq7YTxyzSn4xZW9fWxVaRu5aRA=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@remy/pstree/-/pstree-1.1.0.tgz", + "integrity": "sha512-3rxECj41p0Qkdgoc50VnZpSDTXS+UZGRzTTO+qb3TiZDhuZMmf4z/wApcIeJ878okVq7D9phadgXQD9Kvbq3tQ==", "requires": { "ps-tree": "1.1.0" } diff --git a/package.json b/package.json index 5841da83..e0bc97c3 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "should": "~4.0.0" }, "dependencies": { - "@remy/pstree": "^1.0.1", + "@remy/pstree": "^1.1.0", "chokidar": "^1.7.0", "debug": "^2.6.8", "es6-promise": "^3.3.1",