Documentation
¶
Overview ¶
Package fslock takes an exclusive, non-blocking operating-system lock on a file. The lock, not the file's existence, is the guard: the OS drops it when the holder exits however it exits, so a crashed process leaves no stale lock, and the file is never deleted (deleting a lock file races a process about to open it).
POSIX uses flock(2), which conflicts per open file description; Windows uses LockFileEx, which conflicts per handle. Either way two Acquire calls in one process conflict, which is what a CLI checking for a running server needs. Locks on network filesystems are only as reliable as the filesystem's lock emulation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHeld = errors.New("fslock: lock is held")
ErrHeld means another process (or another Acquire in this one) holds the lock.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is a held lock. Release it exactly once.