Documentation
¶
Overview ¶
Package lock wraps flock(2) on O_CLOEXEC files (spec 6.2, 9).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Held ¶
Held reports whether another open file description holds path's lock. A missing file is not held. It never creates the file.
func HeldRO ¶
HeldRO reports whether any process holds a flock on path without making a free lock look busy to a concurrent non-blocking caller (#55). Linux reads /proc/locks, matching the device and inode it prints; darwin asks fcntl(F_GETLK), which sees flock locks there. Neither takes the lock. A missing file is not held. Without /proc/locks, Linux falls back to a brief try-lock, which can make a free lock look busy for that moment; darwin uses it only if F_GETLK fails. Locks of processes outside this pid namespace are not listed in /proc/locks.
Types ¶
type File ¶
type File struct {
Path string
// contains filtered or unexported fields
}
File is an open lock file. Locks belong to the open file description (flock semantics), so two Opens of one path exclude each other even within one process.
func (*File) LockWait ¶
LockWait retries TryLock every 5 ms until d passes or ctx ends (no unbounded blocking).
func (*File) Rewrite ¶
Rewrite replaces the file's content in place (pwrite + ftruncate), keeping the inode and lock.