fix(rpc): resolve taskkill from system32 in script probes

This commit is contained in:
Vincent Koc
2026-06-21 09:10:48 +02:00
parent fc8542b377
commit 0a7b009647
4 changed files with 212 additions and 93 deletions

View File

@@ -8,6 +8,7 @@ import path from "node:path";
import process from "node:process";
import { setTimeout as delay } from "node:timers/promises";
import { fileURLToPath, pathToFileURL } from "node:url";
import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs";
const PLUGIN_SPEC =
process.env.OPENCLAW_KITCHEN_SINK_NPM_SPEC || "npm:@openclaw/kitchen-sink@latest";
@@ -575,11 +576,12 @@ function commandProcessTreeIsAlive(child) {
}
function signalWindowsProcessTree(pid, signal, runTaskkill = childProcess.spawnSync) {
const taskkillPath = resolveWindowsTaskkillPath();
const args = ["/PID", String(pid), "/T"];
if (signal === "SIGKILL") {
args.push("/F");
}
const result = runTaskkill("taskkill", args, { stdio: "ignore" });
const result = runTaskkill(taskkillPath, args, { stdio: "ignore" });
return !result?.error && result?.status === 0;
}

View File

@@ -10,6 +10,7 @@ import path from "node:path";
import { performance } from "node:perf_hooks";
import { fileURLToPath, pathToFileURL } from "node:url";
import { readBoundedResponseText } from "./lib/bounded-response.mjs";
import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs";
const DEFAULT_METHODS = ["health", "config.get"];
const DEFAULT_ITERATIONS = 10;
@@ -301,16 +302,17 @@ export function signalGatewayProcess(
}
}
if (platform === "win32" && typeof child.pid === "number") {
const taskkillPath = resolveWindowsTaskkillPath();
const args = ["/PID", String(child.pid), "/T"];
if (signal === "SIGKILL") {
args.push("/F");
}
const result = runTaskkill("taskkill", args, { stdio: "ignore" });
const result = runTaskkill(taskkillPath, args, { stdio: "ignore" });
if (!result?.error && result?.status === 0) {
return true;
}
if (signal !== "SIGKILL") {
const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" });
const forceResult = runTaskkill(taskkillPath, [...args, "/F"], { stdio: "ignore" });
if (!forceResult?.error && forceResult?.status === 0) {
return true;
}