|LOCKF(3)||Linux Programmer's Manual||LOCKF(3)|
lockf - apply, test or remove a POSIX lock on an open file
int lockf(int fd, int cmd, off_t len);
Apply, test or remove a POSIX lock on an open file. The file is specified by fd. This call is just an interface for fcntl(2). Valid operations are given below:
- Set an exclusive lock to the file. Only one process may hold an exclusive lock for a given file at a given time. If the file is already locked it blocks until the previous lock is released.
- Same as F_LOCK but never blocks and return error instead if the file is already locked.
- Unlock the file.
- Test the lock: return 0 if fd is unlocked or locked by this process; return -1, set errno to EACCES, if another process holds the lock.
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
- The file is locked and the LOCK_NB flag was selected, or operation is prohibited because the file has been memory-mapped by another process.
- fd is not an open file descriptor.
- Specified lock operation would cause a deadlock.
- An invalid operation was specified in fd.
- Too many segment locks open, lock table is full.
|6 August 1997||Linux 2.0|