1maillock(3MAIL)         User Mailbox Library Functions         maillock(3MAIL)
2
3
4

NAME

6       maillock,  mailunlock,  touchlock - functions to manage lockfile(s) for
7       user's mailbox
8

SYNOPSIS

10       cc [ flag ... ] file ... -lmail [ library ... ]
11       #include <maillock.h>
12
13
14
15       int maillock(const char *user, int retrycnt);
16
17
18       void mailunlock(void);
19
20
21       void touchlock(void);
22
23

DESCRIPTION

25       The maillock() function attempts to create a lockfile  for  the  user's
26       mailfile. If a lockfile already exists, and it has not been modified in
27       the last 5 minutes, maillock() will remove the lockfile and set its own
28       lockfile.
29
30
31       It  is crucial that programs locking mail files refresh their locks  at
32       least every three minutes to maintain the lock. Refresh the lockfile by
33       calling the touchlock() function with no arguments.
34
35
36       The  algorithm  used  to  determine  the age of the lockfile takes into
37       account clock drift between machines using a  network  file  system.  A
38       zero  is  written into the lockfile so that the lock will  be respected
39       by systems running the standard version of System V.
40
41
42       If the lockfile has been modified in the last 5  minutes   the  process
43       will sleep until the lock is available. The sleep algorithm is to sleep
44       for 5 seconds times the attempt number. That is, the first  sleep  will
45       be for 5 seconds, the next sleep will be for 10 seconds, etc. until the
46       number of attempts reaches  retrycnt.
47
48
49       When the lockfile is no longer needed, it should be removed by  calling
50       mailunlock().
51
52
53       The  user  argument is the login name of the user for whose mailbox the
54       lockfile will be created. maillock() assumes that user's mailfiles  are
55       in the ``standard'' place as defined in  <maillock.h>.
56

RETURN VALUES

58       Upon successful completion, .maillock() returns 0. Otherwise it returns
59       −1.
60

FILES

62       /var/mail/*         user mailbox files
63
64
65       /var/mail/*.lock    user mailbox lockfiles
66
67

ATTRIBUTES

69       See attributes(5) for descriptions of the following attributes:
70
71
72
73
74       ┌─────────────────────────────┬─────────────────────────────┐
75       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
76       ├─────────────────────────────┼─────────────────────────────┤
77       │MT-Level                     │Unsafe                       │
78       └─────────────────────────────┴─────────────────────────────┘
79

SEE ALSO

81       libmail(3LIB),attributes(5)
82

NOTES

84       The mailunlock() function will only remove the  lockfile  created  from
85       the  most previous call to maillock(). Calling maillock() for different
86       users without intervening calls to mailunlock()  will  cause  the  ini‐
87       tially  created  lockfile(s) to remain, potentially blocking subsequent
88       message delivery until the current process finally terminates.
89
90
91
92SunOS 5.11                        29 Mar 1999                  maillock(3MAIL)
Impressum