Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
File locks allow processes to synchronize access to a file. Linux provides two file locking system calls: the BSD-derived flock() and the System V-derived fcntl(). Although both system calls are available on most UNIX implementations, only fcntl() locking is standardized in SUSv3.
The flock() system call locks an entire file. Two types of locks may be placed: shared locks, which are compatible with shared locks held by other processes, and exclusive locks, which prevent other processes from placing any type of lock.