mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 05:00:21 +00:00
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:
@@ -1,11 +1,11 @@
|
||||
import { afterEach, expect, test } from "vitest";
|
||||
import { killProcessTree } from "../process/kill-tree.js";
|
||||
import {
|
||||
getFinishedSession,
|
||||
getSession,
|
||||
resetProcessRegistryForTests,
|
||||
} from "./bash-process-registry.js";
|
||||
import { createExecTool } from "./bash-tools.exec.js";
|
||||
import { killProcessTree } from "./shell-utils.js";
|
||||
|
||||
const BACKGROUND_HOLD_CMD = 'node -e "setTimeout(() => {}, 5000)"';
|
||||
const ABORT_SETTLE_MS = process.platform === "win32" ? 200 : 25;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user