Skip to main content

Module liveness

Module liveness 

Source
Expand description

Process liveness detection for reservation reaping.

heddle agent reserve is a one-shot command — the CLI process exits as soon as the reservation has been recorded. Holding a per-session flock for the life of that process therefore buys nothing: the kernel releases the lock on exit(2) long before the next agent ever needs to check liveness.

We instead record (pid, boot_id) at reservation time and check liveness on demand with kill(pid, 0) plus a boot-id comparison. ESRCH means the process is gone. A boot id mismatch means the host rebooted and the PID has been reused — the original owner is also gone.

Enums§

Liveness

Functions§

current_boot_id
Best-effort current boot identifier.
is_owner_alive
Combined check: PID is alive and the recorded boot id matches the current boot id (when both are known). Missing fields collapse to Unknown — callers should not reap on Unknown.
process_alive
true if the process identified by pid is still running. ESRCH from kill(pid, 0) is treated as dead. Any other error (notably EPERM — the process exists but is owned by a different user) is treated as alive: “alive in another uid namespace” still means the reservation might be valid.