pub fn try_exclusive_lock(path: &Path) -> Result<Option<File>, Error>Expand description
Acquire an exclusive, auto-released advisory lock on path — a process
singleton guard for the daemon (#131). Returns the held File on success
(keep it alive to hold the lock), or None if another process already holds
it. flock releases automatically when the file is dropped OR the process
exits/crashes, so a dead holder never wedges the lock the way an O_EXCL
pidfile would. Holding it across the socket probe → unlink → bind closes that
TOCTOU: two daemons can’t both decide a stale socket is theirs to rebind.
Unix-only: it backs the #[cfg(unix)] daemon singleton and relies on
flock, which rustix exposes only on Unix targets.