Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(process): tolerate exit during ownership revalidation

morlutoa0f8b72b7a4c
diff --git a/src/process/ProcessOwnership.ts b/src/process/ProcessOwnership.ts
index 0f501234a..7ec7cefcb 100644
--- a/src/process/ProcessOwnership.ts
+++ b/src/process/ProcessOwnership.ts
@@ -391,6 +391,10 @@ const processOwnershipFailures = async (
if ((await host.environment(member.pid)).REA_PROCESS_RUN_ID !== runId)
failures.push({ pid: member.pid, reason: "run-token-mismatch" });
} catch {
+ try {
+ const live = liveProcesses(await host.listProcesses());
+ if (!live.some(({ pid }) => pid === member.pid)) continue;
+ } catch {}
failures.push({ pid: member.pid, reason: "environment-unreadable" });
}
}
diff --git a/tests/processOwnership.test.ts b/tests/processOwnership.test.ts
index c88886c60..0dfe2666d 100644
--- a/tests/processOwnership.test.ts
+++ b/tests/processOwnership.test.ts
@@ -447,6 +447,35 @@ describe("owned process-group cleanup", () => {
expect(signalGroup).not.toHaveBeenCalled();
});
+ it("accepts a member that exits during ownership revalidation", async () => {
+ const liveLauncher = {
+ pid: 100,
+ parentPid: 1,
+ processGroupId: 100,
+ state: "S",
+ command: "fixture",
+ };
+ const listProcesses = vi
+ .fn<ProcessOwnershipHost["listProcesses"]>()
+ .mockResolvedValueOnce([liveLauncher])
+ .mockResolvedValue([]);
+ const signalGroup = vi.fn();
+ const adapter: ProcessOwnershipHost = {
+ listProcesses,
+ environment: () =>
+ Promise.reject(new Error("process exited before environment read")),
+ signalGroup,
+ };
+
+ await expect(cleanupOwnedProcessGroup(ownership, adapter)).resolves.toEqual(
+ {
+ cleaned: true,
+ signaled: false,
+ },
+ );
+ expect(signalGroup).not.toHaveBeenCalled();
+ });
+
it("ignores exited zombie members during live ownership checks", async () => {
const environment = vi.fn((pid: number) =>
Promise.resolve(pid === 101 ? {} : { REA_PROCESS_RUN_ID: "run-token" }),