Skip to content

Commit

Permalink
fix: Update audit dependencies and remove pstree.remy
Browse files Browse the repository at this point in the history
pstree.remy has a dependency with a compromised dependency

Fixes: remy#1442
Fixes: remy#1451
  • Loading branch information
FallingSnow committed Nov 21, 2018
1 parent 521eb1e commit 438f6cc
Show file tree
Hide file tree
Showing 3 changed files with 5,679 additions and 2,227 deletions.
40 changes: 2 additions & 38 deletions lib/monitor/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var child = null; // the actual child process we spawn
var killedAfterChange = false;
var noop = function () { };
var restart = null;
var psTree = require('pstree.remy');
var killTree = require('tree-kill');
var path = require('path');
var signals = require('./signals');

Expand Down Expand Up @@ -309,43 +309,7 @@ function run(options) {
}

function kill(child, signal, callback) {
if (!callback) {
callback = function () { };
}

if (utils.isWindows) {
// When using CoffeeScript under Windows, child's process is not node.exe
// Instead coffee.cmd is launched, which launches cmd.exe, which starts
// node.exe as a child process child.kill() would only kill cmd.exe, not
// node.exe
// Therefore we use the Windows taskkill utility to kill the process and all
// its children (/T for tree).
// Force kill (/F) the whole child tree (/T) by PID (/PID 123)
exec('taskkill /pid ' + child.pid + ' /T /F');
callback();
} else {
// 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 (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) {
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();
}
});

}
killTree(child.pid, signal, callback);
}

// stubbed out for now, filled in during run
Expand Down
Loading

0 comments on commit 438f6cc

Please sign in to comment.