Skip to main content

Module pidfile

Module pidfile 

Source
Expand description

Shared flock(2)-backed advisory pid-file guard.

This is the single-instance-lock primitive used by both zeph-core::daemon::PidGuard and zeph-scheduler::pidfile::PidFile. The lock is acquired with LOCK_EX | LOCK_NB so a second invocation fails immediately rather than blocking, and the pid file is unlinked when the guard is dropped.

Invariant: the pid file MUST reside on a local filesystem. NFS mounts do not guarantee reliable exclusive locking with flock(2).

Unix only — flock(2) has no portable equivalent, so callers on other platforms must implement their own fallback (see zeph-core::daemon::PidGuard’s non-Unix branch).

Structs§

PidLockGuard
Exclusive, flock(2)-backed guard on a pid file.

Enums§

PidLockError
Error acquiring or maintaining a PidLockGuard.

Functions§

is_process_alive
Check whether a process with the given PID is currently alive.
read_pid_lenient
Best-effort read of the PID stored in the file at path.