






















@@ -52,6 +52,8 @@ import {
5252sampleProcess,
5353sampleWindowsProcessByPort,
5454shouldPrintHelp,
55+signalGateway,
56+signalProcessGroup,
5557stopGateway,
5658summarizeProcessSamples,
5759tailFile,
@@ -280,6 +282,37 @@ describe("kitchen-sink RPC gateway teardown", () => {
280282expect(child.kill).toHaveBeenCalledOnce();
281283});
282284285+it("signals Windows gateway process trees with taskkill", () => {
286+const child = {
287+kill: vi.fn(),
288+pid: 12345,
289+};
290+const killProcess = vi.fn();
291+const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
292+293+expect(
294+signalGateway(child, "SIGTERM", killProcess, {
295+platform: "win32",
296+ runTaskkill,
297+}),
298+).toBe(true);
299+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
300+stdio: "ignore",
301+});
302+303+expect(
304+signalGateway(child, "SIGKILL", killProcess, {
305+platform: "win32",
306+ runTaskkill,
307+}),
308+).toBe(true);
309+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
310+stdio: "ignore",
311+});
312+expect(killProcess).not.toHaveBeenCalled();
313+expect(child.kill).not.toHaveBeenCalled();
314+});
315+283316posixIt("does not trust an exited wrapper while the gateway process group is alive", async () => {
284317const child = Object.assign(new EventEmitter(), {
285318exitCode: 0,
@@ -630,6 +663,31 @@ setInterval(() => {}, 1000);
630663}
631664});
632665666+it("signals Windows command process trees with taskkill", () => {
667+const child = {
668+kill: vi.fn(),
669+pid: 12345,
670+};
671+const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
672+673+signalProcessGroup(child, "SIGTERM", {
674+platform: "win32",
675+ runTaskkill,
676+});
677+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
678+stdio: "ignore",
679+});
680+681+signalProcessGroup(child, "SIGKILL", {
682+platform: "win32",
683+ runTaskkill,
684+});
685+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
686+stdio: "ignore",
687+});
688+expect(child.kill).not.toHaveBeenCalled();
689+});
690+633691posixIt("rejects timed commands that exit cleanly after SIGTERM", async () => {
634692const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-timeout-zero-"));
635693const scriptPath = path.join(root, "term-zero.mjs");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。