pub fn pid_alive(pid: u32) -> boolExpand description
Best-effort liveness check for a process id, with no dependency beyond what the platform ships.
There is no portable way in the standard library to ask “is this pid
alive” - no libc, no sysinfo, nothing magi already depends on binds
the signals API - so this shells out to whatever each platform already
provides: kill -0 on Unix, tasklist on Windows. Both are read-only:
kill -0 sends no signal, it only checks whether one could be sent.
Every uncertain outcome reads as alive, on purpose. This exists so
crate::daemon::sweep_stale_claims can reclaim a lock faster than its
age-based fallback when the owning process is verifiably gone; the risk
on the other side - reclaiming a lock a live process still holds - lets a
second daemon start a second run on the same task, which costs far more
than leaving one lock alone a little longer. So a helper program that is
missing, output that cannot be parsed, or a permission error that merely
proves the pid exists under another account, all count as “alive” rather
than as license to reclaim.