MCPcopy Create free account
hub / github.com/tiann/hapi / killProcess

Function killProcess

cli/src/utils/process.ts:50–66  ·  view source on GitHub ↗
(pid: number, force: boolean = false)

Source from the content-addressed store, hash-verified

48}
49
50export async function killProcess(pid: number, force: boolean = false): Promise<boolean> {
51 if (!Number.isFinite(pid) || pid <= 0) {
52 return false;
53 }
54
55 if (isWindows()) {
56 return killProcessWindows(pid, force);
57 }
58
59 try {
60 process.kill(pid, force ? 'SIGKILL' : 'SIGTERM');
61 await waitForProcessToDie(pid, force);
62 return true;
63 } catch {
64 return false;
65 }
66}
67
68/**
69 * Recursively collects all descendant PIDs of a process (depth-first).

Callers 6

stopRunnerFunction · 0.90
onHappySessionWebhookFunction · 0.90
stopSessionFunction · 0.90

Calls 3

isWindowsFunction · 0.85
killProcessWindowsFunction · 0.85
waitForProcessToDieFunction · 0.85

Tested by

no test coverage detected