1LOCKMAIL(1)                 Double Precision, Inc.                 LOCKMAIL(1)
2
3
4

NAME

6       lockmail - create mail lock files
7

SYNOPSIS

9       lockmail [-r] [-t timeout] {lockfile} {program} [argument...]
10

DESCRIPTION

12       lockmail is a helper utility for working with mailbox files. Mailbox
13       files must be locked to prevent other applications from modifying the
14       mailbox at the same time. Different system use different locking
15       conventions.  lockmail uses two of the most common locking mechanisms
16       in use, which should work reliably on most systems.
17
18       lockfile is the pathname to an existing mailbox file. By default,
19       lockmail tries to lock the mailbox every five seconds (if the mailbox
20       is already locked), and will give up after three minutes. After the
21       mailbox is successfully locked, lockmail runs program as a child
22       process, with any optional arguments. When program terminates, lockmail
23       removes the mailbox lock, and terminates itself.
24

OPTIONS

26       -r
27           If a regular lock fails, try a read-only lock. Use this option to
28           lock mailbox files in a read-only directory.
29
30       -t timeout
31           If the lock attempt fails, try again for up to timeout seconds. The
32           actual timeout is rounded up to the next five second interval (a
33           lock attempt is tried every five seconds).
34

DESCRIPTION

36       This section briefly describes the locking mechanism used by lockmail.
37       lockmail uses three different locking conventions in order to maximize
38       compatibility with other mail software: C-Client folder locks,
39       dot-locks, and file locks.
40
41   C-Client folder locks
42       Mail software based on the C-Client library creates lock files named
43       /tmp/.dddddd.iiiiii. Here, dddddd and iiiiii are the device number and
44       the inode number of the mailbox file (the st_dev and st_ino fields in
45       the inode), in hexadecimal. If the process ID saved in the C-Client
46       folder lock file is not valid, lockmail concludes that it's a stale
47       lock file, and will remove it.
48
49           Note
50           A race condition exists where a C-Client process is killed after it
51           creates a lock file, but before saving its process ID in the lock
52           file. The race window is very small, but it exists. The C-Client
53           library does not appear to ever clear out the lock file.
54
55           lockmail attempts to resolve this race condition by deleting
56           zero-length lock files that are at least five minutes old.
57
58   dot-locks
59       lockmail also creates, and honors dot-lock files. Dot-lock files are
60       first created as temporary files, then linked to lockfile.lock. The
61       link operation fails if the dot-lock file already exists.  lockmail
62       uses an enhanced method of dot-locking, where its process ID, and the
63       name of the server where lockmail is running is also saved in its
64       dot-lock file. If the operation fails due to an existing dot-lock file
65       that was created by another lockmail process on the same server, and
66       the process ID no longer exists, this stale dot-lock file is removed
67       immediately. In all other situations a dot-lock file older than five
68       minutes is considered stale, and removed.
69
70           Note
71           A failure to create a dot-lock file is silently ignored if the
72           reason for the failure is because lockmail does not have the write
73           permission in the dot-lock file's directory. The incoming mail
74           spool directory (usually /var/mail) typically does not have global
75           write permissions, so the attempt to create the dot-lock file in
76           the spool directory will fail, and lockmail will be content with
77           using file-locking only.
78
79   File locks
80       The final locking mechanism lockmail uses is the operating system's
81       file locking facility. If lockmail fails to obtain all three locks,
82       lockmail will sleep for five seconds and try again. The only exception
83       is a failure to create a dot-lock because of no write access to the
84       dot-lock file's directory, which is ignored. If lockmail still fails to
85       obtain all required locks in the amount of time specified by the -t
86       option (or its default value), lockmail will terminate with the
87       EX_TEMPFAIL exit code.
88
89       lockmail runs program after obtaining the last file lock, waits until
90       program terminates, and releases all locks.  program must terminate
91       before any of the locks obtained by lockmail expire, and are considered
92       stale.  lockmail will then terminate with the same exit code as
93       program.
94

EXIT STATUS

96       lockmail terminates with the same exit status as program lockmail
97       terminates with the EX_TEMPFAIL exit status if it was unable to obtain
98       a lock, or if program was killed by a signal.
99

SEE ALSO

101       maildrop(1)[1], sendmail(8).
102

AUTHOR

104       Sam Varshavchik
105           Author
106

NOTES

108        1. maildrop(1)
109           http://www.courier-mta.org/maildrop.html
110
111
112
113Courier Mail Server               07/24/2017                       LOCKMAIL(1)
Impressum