File: lockfile-progs.1

package info (click to toggle)
lockfile-progs 0.1.17
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 76 kB
  • ctags: 28
  • sloc: ansic: 326; makefile: 80
file content (147 lines) | stat: -rw-r--r-- 4,723 bytes parent folder | download | duplicates (3)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'\" t
.\" ** The above line should force tbl to be a preprocessor **
.\" Man page for man
.\"
.\" Copyright (C), 1998-2008, Rob Browning <rlb@defaultvalue.org>
.\"
.\" You may distribute under the terms of the GNU General Public
.\" License as specified in the file COPYING that comes with the
.\" lockfile\-progs distribution.
.\"
.TH lockfile\-progs 1 "2008-02-10" "0.1.12" "Lockfile programs"
.SH NAME
lockfile\-progs \- command\-line programs to safely lock and unlock
files and mailboxes (via liblockfile).
.SH SYNOPSIS
.nf
\fBmail\-lock\fR [\-\-use\-pid] [\-\-retry \fIretry\-count\fR]
\fBmail\-unlock\fR
\fBmail\-touchlock\fR [\-\-oneshot]

\fBlockfile\-create\fR [\-\-use\-pid] [\-\-retry \fIretry\-count\fR] [-\-lock\-name] \fIfilename\fR
\fBlockfile\-remove\fR [-\-lock\-name] \fIfilename\fR
\fBlockfile\-touch\fR [\-\-oneshot] [-\-lock\-name] \fIfilename\fR
\fBlockfile\-check\fR [\-\-use-pid] [-\-lock\-name] \fIfilename\fR
.fi
.SH DESCRIPTION
.PP
Lockfile\-progs provides a set a programs that can be used to lock and
unlock mailboxes and files safely (via liblockfile):

.nf
.RS 4
\fBmail\-lock\fR - lock the current user's mailbox
\fBmail\-unlock\fR - unlock the current user's mailbox
\fBmail\-touchlock\fR - touch the lock on the current user's mailbox

\fBlockfile\-create\fR - lock a given file
\fBlockfile\-remove\fR - remove the lock on a given file
\fBlockfile\-touch\fR - touch the lock on a given file
\fBlockfile\-check\fR - check the lock on a given file
.RE
.fi

By default, the \fIfilename\fR argument refers to the name of the file
to be locked, and the name of the lockfile will be
\fIfilename\fR .lock.  However, if the \-\-lock-name argument is
specified, then \fIfilename\fR will be taken as the name of the
lockfile itself.

Each of the mail locking commands attempts to lock
/var/spool/mail/<user>, where <user> is the name associated with the
effective user ID, as determined by via geteuid(2).

Once a file is locked, the lock must be touched at least once every
five minutes or the lock will be considered stale, and subsequent lock
attempts will succeed.  Also see the \fB\-\-use\-pid\fR option and the
\fBlockfile_create\fR(3) manpage.

The \fBlockfile\-check\fR command tests whether or not a valid lock
already exists.

.SH OPTIONS
.PP .\" --quiet
\fB\-q\fR, \fB\-\-quiet\fR
.RS 4
Suppress any output.  Success or failure will only be indicated by the
exit status.
.RE
.PP .\" --verbose
\fB\-v\fR, \fB\-\-verbose\fR
.RS 4
Enable diagnostic output.
.RE
.PP .\" --lock-name
\fB\-l\fR, \fB\-\-lock\-name\fR
.RS 4
Do not append .lock to the \fIfilename\fR.  This option applies to
\fBlockfile\-create\fR, \fBlockfile\-remove\fR, \fBlockfile-touch\fR,
or \fBlockfile-check\fR.
.RE
.PP .\" --use-pid
\fB\-p\fR, \fB\-\-use\-pid\fR
.RS 4
Write the parent process id (PPID) to the lockfile whenever a lockfile
is created, and use that pid when checking a lock's validity.  See the
\fBlockfile_create\fR(3) manpage for more information.  This option
applies to \fBlockfile\-create\fR and \fBlockfile-check\fR.  NOTE:
this option will not work correctly between machines sharing a
filesystem.
.RE
.PP .\" --oneshot
\fB\-o\fR, \fB\-\-oneshot\fR
.RS 4
Touch the lock and exit immediately.  This option applies to
\fBlockfile\-touch\fR and \fBmail\-touchlock\fR.  When not provided,
these commands will run forever, touching the lock once every minute
until killed.
.RE
.PP .\" --retry
\fB\-r\fR \fIretry\-count\fR, \fB\-\-retry\fR \fIretry\-count\fR
.RS 4
Try to lock \fIfilename\fR \fIretry\-count\fR times before giving up.
Each attempt will be delayed a bit longer than the last (in 5 second
increments) until reaching a maximum delay of one minute between
retries.  If \fIretry\-count\fR is unspecified, the default is 9 which
will give up after 180 seconds (3 minutes) if all 9 lock attempts
fail.

.SH EXAMPLES

.B Locking a file during a lengthy process:

  lockfile\-create /some/file
  lockfile\-touch /some/file &
  # Save the PID of the lockfile\-touch process
  BADGER="$!"   
  do\-something\-important\-with /some/file
  kill "${BADGER}"
  lockfile\-remove /some/file

.SH "EXIT STATUS"
.PP
\fB0\fR
.RS 4
For \fBlockfile\-check\fR this indicates that a valid lock exists,
otherwise it just indicates successful program execution.
.RE
.PP
\fBNot 0\fR
.RS 4
For \fBlockfile\-check\fR a non-zero exit status indicates that the
specified lock does not exist or is not valid.  For other programs it
indicates that some problem was encountered.
.RE
.SH "SEE ALSO"
.nf
\fBmaillock\fR(3)
\fBtouchlock\fR(3)
\fBmailunlock\fR(3)
\fBlockfile_create\fR(3)
\fBlockfile_remove\fR(3)
\fBlockfile_touch\fR(3)
\fBlockfile_check\fR(3)
.fi

.SH AUTHOR
Written by Rob Browning <rlb@defaultvalue.org>