MCPcopy Create free account
hub / github.com/PrimeIntellect-ai/prime-agent / killProcessTree

Function killProcessTree

packages/coding-agent/src/utils/shell.ts:190–214  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

188 * Kill a process and all its children (cross-platform)
189 */
190export function killProcessTree(pid: number): void {
191 if (process.platform === "win32") {
192 // Use taskkill on Windows to kill process tree
193 try {
194 spawn("taskkill", ["/F", "/T", "/PID", String(pid)], {
195 stdio: "ignore",
196 detached: true,
197 });
198 } catch {
199 // Ignore errors if taskkill fails
200 }
201 } else {
202 // Use SIGKILL on Unix/Linux/Mac
203 try {
204 process.kill(-pid, "SIGKILL");
205 } catch {
206 // Fallback to killing just the child if process group kill fails
207 try {
208 process.kill(pid, "SIGKILL");
209 } catch {
210 // Process already dead
211 }
212 }
213 }
214}

Callers 5

runChildProcessFunction · 0.85
abortFunction · 0.85
onAbortFunction · 0.85

Calls 2

spawnFunction · 0.85
killMethod · 0.45

Tested by

no test coverage detected