Contains information about an advisory lock.
#include <fcntl.h> struct flock { pid_t l_pid; pid_t l_tid; short l_type; short l_whence; long ________spare; long ________reserved1; off_t l_start; long ________reserved2; off_t l_len; };
Specifies the process ID of the owner of the lock.
Specifies the thread ID of the owner of the lock.
Specifies the lock type:
Specifies the flag for the starting offset of the lock:
Unused.
Provides padding to resemble the 64-bit structure.
Specifies the relative offset, in bytes, for the lock.
Provides padding to resemble the 64-bit structure.
Specifies the length for the byte range lock. If zero, specifies until EOF.
File locking with the fcntl function is constrained to per-process and is not shared across processes. As long as this remains the case, the value in the l_pid field is a copy of the value in the l_tid field.
When a shared lock (F_RDLCK) is set, other processes can set shared locks on that segment or a portion of it. It prevents other processes from setting an exclusive (F_WRLCK) on any portion of the shared lock area. For a shared lock request to succeed, the file must be opened with read access.
When an exclusive lock (F_WRLCK) is set, other processes cannot set any type of lock on any portion of the exclusive lock area. For an exclusive lock request to succeed, the file must be opened with write access.