chiark / gitweb /
Commit 2.4.5-5 as unpacked
[inn-innduct.git] / doc / man / shlock.1
1 .\" $Revision: 5794 $
2 .TH SHLOCK 1
3 .SH NAME
4 shlock \- create lock files for use in shell scripts
5 .SH SYNOPSIS
6 .B shlock
7 .BI \-p " pid"
8 .BI \-f " name"
9 [
10 .B \-b
11 ]
12 [
13 .B \-u
14 ]
15 [
16 .B \-c
17 ]
18 .SH DESCRIPTION
19 .I Shlock
20 tries to create a lock file named
21 .I name
22 and write the process ID
23 .I pid
24 into it.
25 If the file already exists,
26 .I shlock
27 will read the process ID from the file and test to see if the process
28 is currently running.
29 If the process exists, then the file will not be created.
30 .PP
31 .I Shlock
32 exits with a zero status if it was able to create the lock file, or
33 non-zero if the file refers to currently-active process.
34 .SH OPTIONS
35 .TP
36 .B \-b
37 Process IDs are normally read and written in ASCII.
38 If the ``\-b'' flag is used, then they will be written as a binary
39 .IR int .
40 For compatibility with other systems, the ``\-u'' flag is accepted as
41 a synonym for ``\-b'' since binary locks are used by many UUCP packages.
42 .TP
43 .B \-c
44 If the ``\-c'' flag is used, then
45 .I shlock
46 will not create a lock file, but will instead use the file to see if
47 the lock is held by another program.
48 If the lock is valid, the program will exit with a non-zero status; if
49 the lock is not valid (i.e., invoking
50 .I shlock
51 without the flag would have succeeded), then the program will exit
52 with a zero status.
53 .SH EXAMPLES
54 The following example shows how
55 .I shlock
56 would be used within a shell script:
57 .RS
58 .nf
59 LOCK=<pathrun in inn.conf>/LOCK.send
60 trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
61 if shlock -p $$ -f ${LOCK} ; then
62     # Do appropriate work
63 else
64     echo Locked by `cat ${LOCK}`
65 f\&i
66 .fi
67 .RE
68 .SH BUGS
69 .I shlock
70 assumes that it will not be used in an environment with multiple
71 locks/unlocks in a short time (due to a race condition).  That is,
72 .I shlock
73 is intended for daily or hourly jobs.
74 .SH HISTORY
75 Written by Rich $alz <rsalz@uunet.uu.net> after a description of HDB UUCP
76 locking given by Peter Honeyman.
77 .de R$
78 This is revision \\$3, dated \\$4.
79 ..
80 .R$ $Id: shlock.1 5794 2002-10-01 23:31:53Z vinocur $
81 .SH "SEE ALSO"
82 inn.conf(5)