Flock
Unix system call to place an advisory lock on an entire file.
flock() locks an entire file descriptor. It is simple but does not cross network boundaries—a flock() on an NFS-mounted file is not guaranteed to synchronize. flock() is not standard POSIX—it comes from Berkeley Unix. Many Unix programs use it anyway because it is straightforward to understand: one process takes a lock, other processes block until it is released. fcntl() is the more portable alternative but supports byte-range locking, which is more complex.