mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-22 18:35:21 -06:00
da4ad4110b
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.
21 lines
693 B
TypeScript
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();
|
|
});
|