Skip to content

Commit e9129c0

Browse files
committed
fix: switch to killing using numericals
Fixes #956 Fixes #813
1 parent 770c90d commit e9129c0

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

lib/monitor/run.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var noop = function () { };
1313
var restart = null;
1414
var psTree = require('@remy/pstree');
1515
var path = require('path');
16+
var signals = require('./signals');
1617

1718
function run(options) {
1819
var cmd = config.command.raw;
@@ -290,9 +291,13 @@ function kill(child, signal, callback) {
290291
// configured signal (default: SIGUSR2) signal, which fixes #335
291292
// note that psTree also works if `ps` is missing by looking in /proc
292293
psTree(child.pid, function (err, kids) {
293-
spawn('kill', ['-s', signal, child.pid].concat(kids.map(function (p) {
294-
return p.PID;
295-
}))).on('close', callback);
294+
// make sure we kill from smallest to largest
295+
const pids = kids.map(p => p.PID).concat(child.pid).sort();
296+
297+
pids.forEach(pid => {
298+
exec('kill -' + signals[signal] + ' ' + pid, () => {});
299+
});
300+
callback();
296301
});
297302
}
298303
}

lib/monitor/signals.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
"SIGHUP": "1",
3+
"SIGINT": "2",
4+
"SIGQUIT": "3",
5+
"SIGILL": "4",
6+
"SIGTRAP": "5",
7+
"SIGABRT": "6",
8+
"SIGBUS": "7",
9+
"SIGFPE": "8",
10+
"SIGKILL": "9",
11+
"SIGUSR1": "10",
12+
"SIGSEGV": "11",
13+
"SIGUSR2": "12",
14+
"SIGPIPE": "13",
15+
"SIGALRM": "14",
16+
"SIGTERM": "15",
17+
"SIGSTKFLT": "16",
18+
"SIGCHLD": "17",
19+
"SIGCONT": "18",
20+
"SIGSTOP": "19",
21+
"SIGTSTP": "20",
22+
"SIGTTIN": "21",
23+
"SIGTTOU": "22",
24+
"SIGURG": "23",
25+
"SIGXCPU": "24",
26+
"SIGXFSZ": "25",
27+
"SIGVTALRM": "26",
28+
"SIGPROF": "27",
29+
"SIGWINCH": "28",
30+
"SIGIO": "29",
31+
"SIGPWR": "30",
32+
"SIGSYS": "31",
33+
"SIGRTMIN": "35"
34+
}

0 commit comments

Comments
 (0)