Skip to main content

Module lock

Module lock 

Source
Expand description

An OS advisory lock with holder metadata.

One writer at a time over one record. The lock is the kernel’s, so it is released by drop and by process death and never by a timestamp this tool wrote: a stale lock file cannot outlive the process that took it, and no command has to decide whether an hour-old lock is abandoned.

A busy lock refuses at once, naming the holder. There is no wait and no --force: waiting turns a fast refusal into a hang, and forcing past a live writer is the interleaving the lock exists to stop.

The lock itself is the standard library’s, flock(2) on Unix, so no dependency carries it and no second implementation can disagree with the kernel about what a lock means.

Structs§

Holder
Who holds a lock, for the refusal message.
Lock
A held advisory lock. Dropping it releases the lock.

Enums§

Mode
Whether a lock excludes other readers.