Skip to main content

Module process_identity

Module process_identity 

Source
Expand description

Process-birth identities in the incumbent’s exact spelling. What: Process-birth identities: a string that names one process for its whole life and changes when its PID is reused, in the incumbent’s exact spelling. Why: Every lock and transaction records its owner’s PID and birth identity; an owner is alive only while its PID names a process with the recorded identity. Both wrappers judge each other’s locks, so the strings must agree byte for byte (src/policy-engine/commit-transaction-process-identity.ts; the decision in doc/handover/cli-git-rust-implementation.md, “Adopted without a question”).

In TS you’d write (pseudocode):

const identity = await resolveProcessBirthIdentity(pid); // 'linux:8423337' or PROCESS_IDENTITY_ABSENT

Structs§

MalformedStat
What: The one way a /proc/<pid>/stat text can be malformed for this purpose. Why: The caller knows the PID and turns this into a named error.

Enums§

ProcessIdentityError
What: Why a birth identity could not be decided. Absence (the process exited) is not an error; these are states the incumbent also throws on. Why: A lock acquirer that cannot tell whether an owner lives must stop, not guess.

Functions§

command_identity
What: The identity a platform inspector printed, as <prefix>:<trimmed output>, or nothing when it printed only whitespace. &[u8] borrows the raw standard output. Why: On macOS and Windows the incumbent runs a command and trims its output; empty output means the process is gone.
current_birth_identity
What: The birth identity of this process, computed once per process. Why: Every lock this process takes records it, and on macOS and Windows each computation starts a process.
darwin_identity_arguments
What: The arguments the incumbent passes to ps for one PID on macOS. Why: ps -o lstart= prints the start time in the C locale; running it reproduces the incumbent’s string by construction.
linux_identity_from_stat
What: The birth identity in one /proc/<pid>/stat text, or nothing for an exited process. Result<Option<String>, MalformedStat> is “an identity, nothing, or a malformed record”. Why: The incumbent cuts after the last ) (the command name may hold spaces and )), skips ) , trims, splits on single spaces, treats states Z and X as exited (a zombie under a container init that never reaps keeps its PID forever), and answers linux: plus the start tick. An empty start field is malformed.
process_birth_identity
What: The birth identity of the process pid names now, or nothing when none runs. i64 holds any PID a record can carry. Why: This is the one question every liveness check asks.
signal_probe
What: Whether a signal could be sent to pid (it names some process), on Unix. Ok(false) means no such process; an error is a refusal such as EPERM. Why: The incumbent’s processIsAlive asks kill(pid, 0) before comparing identities; a process of another account answers EPERM, which callers judge themselves.
windows_identity_arguments
What: The arguments the incumbent passes to PowerShell for one PID on Windows. Vec<String> is an owned list of owned text. Why: The Windows identity is whatever this exact command prints, so running the same command reproduces it by construction; the conversion through GetProcessTimes that would avoid PowerShell is unproven (doc/handover/cli-git-native-transactions.md).