Skip to main content

Module liveness

Module liveness 

Source
Expand description

Process identity probing, the pid sentinels and the per-side liveness rules.

Structs§

Sentinel
<pid>:<boot_id>:<starttime>.
SystemProbe

Enums§

Liveness
RebindOutcome
Side

Constants§

STARTING_MS 🔒
A side with no sentinel yet is starting for this long after its clock origin.

Traits§

ProcessProbe

Functions§

boot_matches
Exact on POSIX; within 120 s on Windows.
boot_matches_windows
Windows boot values are epoch seconds truncated to the minute; clock adjustments drift them, a reboot moves them by far more: equal within 120 s.
days_from_civil 🔒
highest_tui_generation 🔒
The highest generation that has a tui-pid file.
mtime_ms 🔒
pair_file 🔒
parse_boot_output
The PowerShell boot expression’s stdout as a boot value: digits only, else None.
parse_kern_boottime
sysctl -n kern.boottime -> epoch seconds (the sec = N field).
parse_lstart
ps -o lstart= output (Sun Oct 18 12:34:56 2026, no zone) parsed as UTC to epoch seconds. Callers run ps with TZ=UTC.
parse_proc_stat_starttime
Field 22 of a /proc/<pid>/stat line: the 20th whitespace-separated token after the last ) (the comm field may itself contain ) and spaces).
rebind_on_spawn
An MCP server that starts under OPENCODE_CTL_PAIR: unless claude-pid names an alive process, drop claude-exited and dead-seen and write claude-pid from the parent process.
remove_if_present 🔒
sentinel_alive
The pid exists, its boot value matches and its start time is exactly the sentinel’s.
sentinel_state 🔒
side_liveness
One side’s liveness, re-derived from the files on every call (spec Pairing, liveness values).
starting_or_unknown 🔒
starting while the clock origin is younger than 30 s, else unknown (also without an origin).
sweep_stdout_dirs
Delete <home>/stdout/<pid>-<starttime> directories whose process is dead or whose start time differs from the live process’s (a reused pid). Names of any other shape are left alone. Returns the directories removed.