()
| 14 | * after a short grace period. |
| 15 | */ |
| 16 | export function killTrackedProcesses(): void { |
| 17 | const alive: ChildProcess[] = []; |
| 18 | for (const proc of tracked) { |
| 19 | if (!proc.killed) { |
| 20 | try { |
| 21 | proc.kill("SIGTERM"); |
| 22 | alive.push(proc); |
| 23 | } catch { |
| 24 | // Already exited between the check and the kill. |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | tracked.clear(); |
| 29 | |
| 30 | if (alive.length === 0) return; |
| 31 | |
| 32 | setTimeout(() => { |
| 33 | for (const proc of alive) { |
| 34 | try { |
| 35 | proc.kill("SIGKILL"); |
| 36 | } catch { |
| 37 | // Already exited. |
| 38 | } |
| 39 | } |
| 40 | }, 500).unref(); |
| 41 | } |
no test coverage detected