Module sys/lock

sys/lock

Advisory file locking.

Synchronous wrapper for POSIX flock(). Returns 0 on success, -errno on failure.

Operations can be OR'd with LOCK_NB for non-blocking. LOCK_NB returns -EWOULDBLOCK (-11) if the lock cannot be acquired immediately.

Functions

flock function
fn(fd : i32, operation : i32) -> i32

Parameters

NameTypeNotes
fdi32
operationi32

Returns: i32

Constants

LOCK_SH constant i32

Value: 1

LOCK_EX constant i32

Value: 2

LOCK_NB constant i32

Value: 4

LOCK_UN constant i32

Value: 8