Replace killProcessTree references to shell-utils with process/kill-tree (#55213)

* Replace killProcessTree references to shell-utils with process/kill-tree

* Address grace timeout comment

* Align with existing process kill behavior

* bash: fail stop without pid

* bash: lazy-load kill tree on stop

---------

Co-authored-by: Jacob Tomlinson <jtomlinson@nvidia.com>
This commit is contained in:
mappel-nv
2026-03-27 07:25:56 -04:00
committed by GitHub
parent d80b67124b
commit 9d58f9e24f
4 changed files with 128 additions and 35 deletions

View File

@@ -1,4 +1,3 @@
import { spawn } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
@@ -166,27 +165,3 @@ export function sanitizeBinaryOutput(text: string): string {
}
return chunks.join("");
}
export function killProcessTree(pid: number): void {
if (process.platform === "win32") {
try {
spawn("taskkill", ["/F", "/T", "/PID", String(pid)], {
stdio: "ignore",
detached: true,
});
} catch {
// ignore errors if taskkill fails
}
return;
}
try {
process.kill(-pid, "SIGKILL");
} catch {
try {
process.kill(pid, "SIGKILL");
} catch {
// process already dead
}
}
}