2 .TH lock 3 "23 May 1999" "Straylight/Edgeware" "mLib utilities library"
4 lock \- oversimplified file locking interface
8 .B "#include <mLib/lock.h>"
10 .BI "int lock_file(int " fd ", unsigned " how );
15 function provides an extremely simplistic interface to POSIX
17 locking. It locks only entire files, not sections of files. It doesn't
18 have a nonblocking `is this file locked?' function.
22 should be a file descriptor on an open file, and
24 is a constant which describes how the file is to be locked. The
30 Lock the file exclusively. Attempts to lock the file exclusively or
31 nonexclusively will fail until the file is unlocked.
34 Lock the file nonexclusively. Until the file is unlocked, attempts to
35 lock it exclusively will fail, but other nonexclusive locks will
39 Unlocks a locked file. Any locks afterwards can succeed.
43 function will block if it can't obtain a lock immediately. It will time
44 itself out after a short while (10 seconds in the current
45 implementation) if the lock doesn't become available.
49 returns zero. On failure, \-1 is returned, and
51 is set to an appropriate value. Most of the error returns are from
53 (q.v.). If the lock operation times out,
61 Mark Wooding, <mdw@distorted.org.uk>