Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stripping the SIG prefix for POSIX compliance #957

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions lib/monitor/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,33 @@ 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
// it's own child, and that can't be killed by nodemon, so psTree gives us
// 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();
});
Expand Down