Skip to content

Commit 1171fc1

Browse files
committed
fix: nodemon reporting crash
Fixes #1173
1 parent bd9d595 commit 1171fc1

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/monitor/run.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,21 @@ function kill(child, signal, callback) {
290290
// an array of PIDs that have spawned under nodemon, and we send each the
291291
// configured signal (default: SIGUSR2) signal, which fixes #335
292292
// note that psTree also works if `ps` is missing by looking in /proc
293+
const sig = signal.replace('SIG', '');
293294
psTree(child.pid, function (err, kids) {
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();
295+
if (psTree.hasPS) {
296+
spawn('kill', ['-s', sig, child.pid].concat(kids.map(p => p.PID)))
297+
.on('close', callback);
298+
} else {
299+
// make sure we kill from smallest to largest
300+
const pids = kids.map(p => p.PID).concat(child.pid).sort();
301+
pids.forEach(pid => {
302+
exec('kill -' + signals[signal] + ' ' + pid, () => { });
303+
});
304+
callback();
305+
}
301306
});
307+
302308
}
303309
}
304310

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"should": "~4.0.0"
5353
},
5454
"dependencies": {
55-
"@remy/pstree": "^1.0.1",
55+
"@remy/pstree": "^1.1.0",
5656
"chokidar": "^1.7.0",
5757
"debug": "^2.6.8",
5858
"es6-promise": "^3.3.1",

0 commit comments

Comments
 (0)