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