Files
openclaw/test/helpers/process-wait.test.ts
T
Peter Steinberger da4ad4110b fix(process): treat zombie lock owners as dead (#125658)
Linux signal-zero probes succeed for zombie processes. Reclaim memory promotion and session usage locks only when their exact zombie owner is still current, and route shared test waits through the canonical zombie-aware PID helper.
2026-08-17 23:55:08 -07:00

21 lines
693 B
TypeScript

import fsSync from "node:fs";
import { afterEach, expect, it, vi } from "vitest";
import { waitForDead } from "./process-wait.js";
afterEach(() => {
vi.restoreAllMocks();
});
it("stops waiting when a Linux process is a zombie", async () => {
vi.spyOn(process, "platform", "get").mockReturnValue("linux");
vi.spyOn(process, "kill").mockImplementation(() => true);
vi.spyOn(fsSync, "readFileSync").mockImplementation((filePath) => {
if (String(filePath) === "/proc/42/status") {
return "Name:\tworker\nState:\tZ (zombie)\nPid:\t42\n";
}
throw new Error(`unexpected read: ${String(filePath)}`);
});
await expect(waitForDead(42, 20)).resolves.toBeUndefined();
});