fix(security): kill timed out exec process trees

This commit is contained in:
Vincent Koc
2026-06-18 00:37:57 +02:00
parent 9bd6ff4c14
commit 39dc92efb7
6 changed files with 155 additions and 6 deletions
+17
View File
@@ -0,0 +1,17 @@
import type { ChildProcess } from "node:child_process";
import { signalProcessTree } from "./kill-tree.js";
export function shouldDetachChildForProcessTree(): boolean {
return process.platform !== "win32";
}
export function forceKillChildProcessTree(child: Pick<ChildProcess, "kill" | "pid">): void {
if (typeof child.pid === "number" && child.pid > 0) {
signalProcessTree(child.pid, "SIGKILL", {
detached: shouldDetachChildForProcessTree(),
});
return;
}
child.kill("SIGKILL");
}