MCPcopy Create free account
hub / github.com/arctic-cli/interface / killTree

Function killTree

packages/arctic/src/shell/shell.ts:9–35  ·  view source on GitHub ↗
(proc: ChildProcess, opts?: { exited?: () => boolean })

Source from the content-addressed store, hash-verified

7
8export namespace Shell {
9 export async function killTree(proc: ChildProcess, opts?: { exited?: () => boolean }): Promise<void> {
10 const pid = proc.pid
11 if (!pid || opts?.exited?.()) return
12
13 if (process.platform === "win32") {
14 await new Promise<void>((resolve) => {
15 const killer = spawn("taskkill", ["/pid", String(pid), "/f", "/t"], { stdio: "ignore" })
16 killer.once("exit", () => resolve())
17 killer.once("error", () => resolve())
18 })
19 return
20 }
21
22 try {
23 process.kill(-pid, "SIGTERM")
24 await Bun.sleep(SIGKILL_TIMEOUT_MS)
25 if (!opts?.exited?.()) {
26 process.kill(-pid, "SIGKILL")
27 }
28 } catch (_e) {
29 proc.kill("SIGTERM")
30 await Bun.sleep(SIGKILL_TIMEOUT_MS)
31 if (!opts?.exited?.()) {
32 proc.kill("SIGKILL")
33 }
34 }
35 }
36 const BLACKLIST = new Set(["fish", "nu"])
37
38 function fallback() {

Callers

nothing calls this directly

Calls 2

spawnFunction · 0.85
resolveFunction · 0.85

Tested by

no test coverage detected