mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-08 15:33:57 +00:00
25 lines
679 B
TypeScript
25 lines
679 B
TypeScript
import type { ChildProcess } from "node:child_process";
|
|
import { signalProcessTree } from "./kill-tree.js";
|
|
|
|
export function shouldDetachChildForProcessTree(): boolean {
|
|
return process.platform !== "win32";
|
|
}
|
|
|
|
export function signalChildProcessTree(
|
|
child: Pick<ChildProcess, "kill" | "pid">,
|
|
signal: "SIGTERM" | "SIGKILL",
|
|
): void {
|
|
if (typeof child.pid === "number" && child.pid > 0) {
|
|
signalProcessTree(child.pid, signal, {
|
|
detached: shouldDetachChildForProcessTree(),
|
|
});
|
|
return;
|
|
}
|
|
|
|
child.kill(signal);
|
|
}
|
|
|
|
export function forceKillChildProcessTree(child: Pick<ChildProcess, "kill" | "pid">): void {
|
|
signalChildProcessTree(child, "SIGKILL");
|
|
}
|