-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
19 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
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,23 +1,22 @@ | ||
import deb from "debug"; | ||
import psTree from "ps-tree"; | ||
import util from "util"; | ||
const debug = deb("end-child-processes"); | ||
const psTreeA = util.promisify(psTree); | ||
import deb from "debug" | ||
import psTree from "ps-tree" | ||
import util from "util" | ||
const debug = deb("end-child-processes") | ||
const psTreeA = util.promisify(psTree) | ||
|
||
export async function endChildProcesses(): Promise<void> { | ||
const children = await psTreeA(process.pid); | ||
const children = await psTreeA(process.pid) | ||
for (const child of children) { | ||
if (child.COMMAND === "ps") { | ||
continue; | ||
continue | ||
} | ||
const processID = parseInt(child.PID, 10); | ||
debug(`ending child process ${processID}: ${child.COMMAND}`); | ||
const processID = parseInt(child.PID, 10) | ||
debug(`ending child process ${processID}: ${child.COMMAND}`) | ||
try { | ||
process.kill(processID); | ||
process.kill(processID) | ||
} catch (e) { | ||
debug( | ||
`cannot kill process ${processID} (${child.COMMAND}): ${e.message}` | ||
); | ||
// eslint-disable-next-line | ||
debug(`cannot kill process ${processID} (${child.COMMAND}): ${e.message}`) | ||
} | ||
} | ||
} |