File: maillock.3

package info (click to toggle)
liblockfile 0.1-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 80 kB
  • ctags: 29
  • sloc: ansic: 306; makefile: 90; sh: 50
file content (64 lines) | stat: -rw-r--r-- 1,922 bytes parent folder | download | duplicates (2)
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
55
56
57
58
59
60
61
62
63
64
.TH MAILOCK 3  "08 March 1998" "Linux Manpage" "Linux Programmer's Manual"
.SH NAME
maillock, mailunlock, touchlock \- manage mailbox lockfiles
.SH SYNOPSIS
.B #include <maillock.h>
.sp
.BI "cc [ "flag " ... ] "file " ... -llockfile [ "library " ] "
.sp
.BI "int maillock( const char *" user ", int " retrycnt " );"
.br
.BI "void mailunlock( "void " );"
.br
.BI "void touchlock( "void " );"
.SH DESCRIPTION
The
.B maillock
function tries to create a lockfile for the users mailbox. This mailbox is
typically located in
.B /var/spool/mail.
The name of the lockfile then becomes
.B /var/spool/mail/username.lock.
.B Maillock
uses an NFS safe algorithm that is documented in
.BR lockfile_create "(3)".
.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 touchlock
function is provided: while holding the lock, it needs to be refreshed
regulary (every minute or so) by calling
.B touchlock "() ".
.PP
Finally the
.B mailunlock
function removes the lockfile.

.SH RETURN VALUES
.B maillock
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

.SH NOTES
These functions are not thread safe. If you need thread safe functions,
or you need to lock other mailbox (like) files that are not in the
standard location, use
.BR lockfile_create "(3)"
instead.

.SH FILES
/var/spool/mail/user.lock,
.br
/usr/lib/liblockfile.so.0

.SH "SEE ALSO"
.BR lockfile_create "(3), " lockfile_touch " (3), " lockfile_remove (3)