






















@@ -571,6 +571,89 @@ describe("secret provider integration proof harness", () => {
571571}
572572});
573573574+it("signals Windows command process trees with graceful taskkill first", async () => {
575+const proof = await import(
576+`${pathToFileURL(proofScriptPath).href}?case=windows-command-${Date.now()}`
577+);
578+const child = {
579+kill: vi.fn(),
580+pid: 12345,
581+};
582+const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
583+584+proof.terminateProcessTree(child, "SIGTERM", {
585+platform: "win32",
586+ runTaskkill,
587+});
588+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
589+stdio: "ignore",
590+});
591+592+proof.terminateProcessTree(child, "SIGKILL", {
593+platform: "win32",
594+ runTaskkill,
595+});
596+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
597+stdio: "ignore",
598+});
599+expect(child.kill).not.toHaveBeenCalled();
600+});
601+602+it("force-kills Windows command trees when graceful taskkill fails", async () => {
603+const proof = await import(
604+`${pathToFileURL(proofScriptPath).href}?case=windows-command-fallback-${Date.now()}`
605+);
606+const child = {
607+kill: vi.fn(),
608+pid: 12345,
609+};
610+const runTaskkill = vi
611+.fn()
612+.mockReturnValueOnce({ error: undefined, status: 1 })
613+.mockReturnValueOnce({ error: undefined, status: 0 });
614+615+proof.terminateProcessTree(child, "SIGTERM", {
616+platform: "win32",
617+ runTaskkill,
618+});
619+620+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
621+stdio: "ignore",
622+});
623+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
624+stdio: "ignore",
625+});
626+expect(child.kill).not.toHaveBeenCalled();
627+});
628+629+it("signals Windows PTY process trees with taskkill", async () => {
630+const proof = await import(
631+`${pathToFileURL(proofScriptPath).href}?case=windows-pty-${Date.now()}`
632+);
633+const child = {
634+kill: vi.fn(),
635+pid: 12345,
636+};
637+const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
638+639+proof.signalPtyProcessTree(child, "SIGHUP", {
640+platform: "win32",
641+ runTaskkill,
642+});
643+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
644+stdio: "ignore",
645+});
646+647+proof.signalPtyProcessTree(child, "SIGKILL", {
648+platform: "win32",
649+ runTaskkill,
650+});
651+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
652+stdio: "ignore",
653+});
654+expect(child.kill).not.toHaveBeenCalled();
655+});
656+574657it.runIf(process.platform !== "win32")("kills timed-out command process groups", async () => {
575658const root = makeTempDir();
576659const markerPath = path.join(root, "command-descendant-marker.txt");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。