File: lockfile_create.3

package info (click to toggle)
liblockfile 0.1-6
  • links: PTS
  • area: main
  • in suites: slink
  • size: 80 kB
  • ctags: 30
  • sloc: ansic: 311; makefile: 90; sh: 50
file content (54 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
.TH LOCKFILE_CREATE 3  "05 October 1998" "Linux Manpage" "Linux Programmer's Manual"
.SH NAME
lockfile_create, lockfile_remove, lockfile_touch \- manage lockfiles
.SH SYNOPSIS
.B #include <lockfile.h>
.sp
.BI "cc [ "flag " ... ] "file " ... -llockfile [ "library " ] "
.sp
.BI "int lockfile_create( const char *" lockfile ", int " retrycnt " );"
.br
.BI "int lockfile_remove( const char *" lockfile " );"
.br
.BI "int lockfile_touch( const char *" lockfile " );"
.SH DESCRIPTION
The
.B lockfile_create
function creates an empty lockfile in an NFS safe way. This manual
page should describe the details here but doesn't as you can see.
.PP
There is no good way to see if a lockfile is stale. Therefore if the lockfile
is older then 5 minutes, it will be removed. That is why the
.B lockfile_touch
function is provided: while holding the lock, it needs to be refreshed
regulary (every minute or so) by calling
.B lockfile_touch "() ".
.PP
Finally the
.B lockfile_remove
function removes the lockfile.

.SH RETURN VALUES
.B lockfile_create
returns one of the following status codes:
.nf

   #define L_SUCCESS   0    /* Lockfile created                     */
   #define L_NAMELEN   1    /* Recipient name too long (> 13 chars) */
   #define L_TMPLOCK   2    /* Error creating tmp lockfile          */
   #define L_TMPWRITE  3    /* Can't write pid int tmp lockfile     */
   #define L_MAXTRYS   4    /* Failed after max. number of attempts */
   #define L_ERROR     5    /* Unknown error; check errno           */

.fi
.B lockfile_touch
and
.B lockfile_remove
return 0 on success. On failure -1 is returned and
.I errno
is set appropriately.
.SH FILES
/usr/lib/liblockfile.so.0

.SH "SEE ALSO"
.BR maillock "(3), " touchlock " (3), " mailunlock (3)