-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaces tree-kill with custom implementation; fixes some security au…
…dit things
- Loading branch information
1 parent
be854a6
commit 9182638
Showing
7 changed files
with
203 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
dist | ||
*.tgz | ||
logs | ||
logs | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var cp = require('child_process'); | ||
|
||
var child = cp.exec("node -e 'while (true);'"); | ||
console.log(`Running child with pid ${child.pid}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import psTree from "ps-tree" | ||
|
||
/** | ||
* Sends the specified signal to the provided pid and all of its descendents. | ||
* | ||
* Custom implementation of 'tree-kill'. It had some issues with detecting and | ||
* stopping grandchildren. It uses `pgrep -P PID` under the hood which does not | ||
* return the full tree of pids. | ||
*/ | ||
export const treeKill = (pid: number, signal: string = 'SIGTERM'): Promise<number[]> => { | ||
return new Promise((resolve, reject) => { | ||
psTree(pid, (err, children) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
const childPids = children.map(child => Number(child.PID)) | ||
childPids.forEach(childPid => process.kill(childPid, signal)) | ||
resolve(childPids); | ||
} | ||
}); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters