Documentation
¶
Overview ¶
Package lease holds a process's claim on a file with flock: a process holds the exclusive lock for as long as it lives, and others probe it with a shared lock. The kernel drops the lock however the holder ends, so a probe never mistakes a dead holder, or a process that reused its PID, for a live one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHeld = errors.New("the lease is held by another process")
ErrHeld says another process holds the lease.
Functions ¶
func Hold ¶
Hold opens path, creating it with mode, and takes its exclusive lock, retrying for up to wait so that a probe holding the shared lock for an instant does not read as a holder. The lease lasts until the returned file is closed or the process ends. The file itself is never removed: a process that opened it before a removal could otherwise lock a file no one else sees.
func Probe ¶
Probe reports whether another process holds the lease at path. A missing file is a lease no one holds. When no one holds it, whileFree, if set, runs while Probe holds the shared lock, so no holder can start meanwhile; its error is returned. Any other failure is returned rather than read as free.
Types ¶
This section is empty.