





















@@ -313,6 +313,34 @@ describe("kitchen-sink RPC gateway teardown", () => {
313313expect(child.kill).not.toHaveBeenCalled();
314314});
315315316+it("force-kills Windows gateway process trees when graceful taskkill fails", () => {
317+const child = {
318+kill: vi.fn(),
319+pid: 12345,
320+};
321+const killProcess = vi.fn();
322+const runTaskkill = vi
323+.fn()
324+.mockReturnValueOnce({ error: undefined, status: 1 })
325+.mockReturnValueOnce({ error: undefined, status: 0 });
326+327+expect(
328+signalGateway(child, "SIGTERM", killProcess, {
329+platform: "win32",
330+ runTaskkill,
331+}),
332+).toBe(true);
333+334+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
335+stdio: "ignore",
336+});
337+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
338+stdio: "ignore",
339+});
340+expect(killProcess).not.toHaveBeenCalled();
341+expect(child.kill).not.toHaveBeenCalled();
342+});
343+316344posixIt("does not trust an exited wrapper while the gateway process group is alive", async () => {
317345const child = Object.assign(new EventEmitter(), {
318346exitCode: 0,
@@ -688,6 +716,30 @@ setInterval(() => {}, 1000);
688716expect(child.kill).not.toHaveBeenCalled();
689717});
690718719+it("force-kills Windows command process trees when graceful taskkill fails", () => {
720+const child = {
721+kill: vi.fn(),
722+pid: 12345,
723+};
724+const runTaskkill = vi
725+.fn()
726+.mockReturnValueOnce({ error: undefined, status: 1 })
727+.mockReturnValueOnce({ error: undefined, status: 0 });
728+729+signalProcessGroup(child, "SIGTERM", {
730+platform: "win32",
731+ runTaskkill,
732+});
733+734+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
735+stdio: "ignore",
736+});
737+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
738+stdio: "ignore",
739+});
740+expect(child.kill).not.toHaveBeenCalled();
741+});
742+691743posixIt("rejects timed commands that exit cleanly after SIGTERM", async () => {
692744const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-timeout-zero-"));
693745const scriptPath = path.join(root, "term-zero.mjs");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。