MCPcopy Create free account
hub / github.com/Snapchat/Valdi / killTree

Function killTree

valdi/vscode_debugger/src/targets/node/killTree.ts:11–41  ·  view source on GitHub ↗
(processId: number, logger: ILogger)

Source from the content-addressed store, hash-verified

9 * Kills the tree of processes starting at the given parent ID.
10 */
11export function killTree(processId: number, logger: ILogger): boolean {
12 if (process.platform === 'win32') {
13 const windir = process.env['WINDIR'] || 'C:\\Windows';
14 const TASK_KILL = join(windir, 'System32', 'taskkill.exe');
15
16 // when killing a process in Windows its child processes are *not* killed but become root processes.
17 // Therefore we use TASKKILL.EXE
18 try {
19 execSync(`${TASK_KILL} /F /T /PID ${processId}`);
20 return true;
21 } catch (err) {
22 logger.error(LogTag.RuntimeException, 'Error running taskkill.exe', err);
23 return false;
24 }
25 } else {
26 // on linux and OS X we kill all direct and indirect child processes as well
27 try {
28 const cmd = join(__dirname, './terminateProcess.sh');
29 const r = spawnSync('sh', [cmd, processId.toString()]);
30 if (r.stderr && r.status) {
31 logger.error(LogTag.RuntimeException, 'Error running terminateProcess', r);
32 return false;
33 }
34
35 return true;
36 } catch (err) {
37 logger.error(LogTag.RuntimeException, 'Error running terminateProcess', err);
38 return false;
39 }
40 }
41}

Callers 5

reactTest.tsFile · 0.90
killMethod · 0.90
stopMethod · 0.90
gotTelemeteryMethod · 0.90
stopMethod · 0.90

Calls 2

errorMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected