Copyright (C) 2000-2012 |
Manpages FLOCKSection: Linux Programmer's Manual (2)Updated: 1998-12-11 Index Return to Main Contents NAMEflock - apply or remove an advisory lock on an open fileSYNOPSIS#include <sys/file.h>int flock(int fd, int operation) DESCRIPTIONApply or remove an advisory lock on an open file. The file is specified by fd. Valid operations are given below:
A single file may not simultaneously have both shared and exclusive locks. A file is locked (i.e., the inode), not the file descriptor. So, dup(2) and fork(2) do not create multiple instances of a lock. RETURN VALUEOn success, zero is returned. On error, -1 is returned, and errno is set appropriately.ERRORS
CONFORMING TO4.4BSD (the flock(2) call first appeared in 4.2BSD).NOTESflock(2) does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given a sufficiently recent version of Linux and a server which supports locking.flock(2) and fcntl(2) locks have different semantics with respect to forked processes and dup(2). SEE ALSOopen(2), close(2), dup(2), execve(2), fcntl(2), fork(2), lockf(3)There are also locks.txt and mandatory.txt in /usr/src/linux/Documentation.
IndexThis document was created by man2html, using the manual pages. Time: 11:30:25 GMT, December 14, 2024 |