Files
rea/src/process/ProcessOwnershipIdentity.ts
T
morluto aece2e7e16 fix(process): preserve ownership through termination and cleanup (#9891)
* fix(process): revalidate ownership before signaling

* fix(process): retain cleanup ownership until completion

* fix(process): keep omitted live descendants unresolved

A non-empty process table that omits a retained live PID cannot authorize a signal or certify cleanup. An empty table can still describe a token-verified owner.

* fix(process): read omitted Darwin run tokens by PID

A live identity that ps omitted was still validated through Darwin
environment(), which rejects any PID absent from a second process table.
Ask the native reader for that PID directly so the launch token can bind.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-11 17:20:53 +08:00

31 lines
1.1 KiB
TypeScript

import { matchesOwnedProcessCommand } from "./ProcessCommandIdentity.js";
import type {
OwnedProcessGroup,
ProcessTableEntry,
} from "./ProcessOwnership.js";
/** Compare a live launcher against the identity committed at process launch. */
export const launcherIdentityFailure = (
launcher: Pick<ProcessTableEntry, "parentPid" | "processGroupId"> & {
readonly command?: string;
},
ownership: OwnedProcessGroup,
): string | null => {
if (launcher.processGroupId !== ownership.processGroupId)
return "owned launcher process-group identity did not match";
if (
ownership.expectedParentPid !== undefined &&
launcher.parentPid !== ownership.expectedParentPid
)
return "owned launcher parent identity did not match";
if (ownership.expectedCommand !== undefined) {
if (launcher.command === undefined)
return "owned launcher command identity could not be verified";
if (
!matchesOwnedProcessCommand(launcher.command, ownership.expectedCommand)
)
return `owned launcher command identity did not match (observed=${launcher.command}; expected=${ownership.expectedCommand})`;
}
return null;
};