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, read from /proc/locks without taking the lock, so an observer never makes a free lock look busy to a concurrent non-blocking caller. It matches the device and inode /proc/locks prints. A missing file is not held; if /proc/locks is unreadable it falls back to Held. Locks of processes outside this pid namespace are not listed there.
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.