1SHLOCK(1)                 InterNetNews Documentation                 SHLOCK(1)
2
3
4

NAME

6       shlock - Create lock files for use in shell scripts
7

SYNOPSIS

9       shlock [-b|-c|-u] -f name -p pid
10

DESCRIPTION

12       shlock tries to create a lock file named name and write the process ID
13       pid into it.  If the file already exists, shlock will read the process
14       ID from the file and test to see whether the process is currently
15       running.  If the process exists, then the file will not be created.
16       shlock exits with a zero status if it could create the lock file, or
17       non-zero if the file refers to a currently active process.
18

OPTIONS

20       -b  Process IDs are normally read and written in ASCII.  If the -b flag
21           is used, then they will be written as a binary int.
22
23       -c  If the -c flag is used, then shlock will not create a lock file,
24           but will instead use the file to see if the lock is held by another
25           program.  If the lock is valid, the program will exit with a non-
26           zero status; if the lock is not valid (i.e. invoking shlock without
27           the flag would have succeeded), then the program will exit with a
28           zero status.
29
30       -f name
31           name is the name of the lock file shlock attempts to create.  If
32           the file already exists, it will read the process ID from the file
33           and exit with a non-zero status if this process is currently
34           active.
35
36       -p pid
37           pid is the process ID to write into the file name.
38
39       -u  For compatibility with other systems, the -u flag is accepted as a
40           synonym for -b since binary locks are used by many UUCP packages.
41

EXAMPLES

43       The following example shows how shlock would be used within a shell
44       script:
45
46           LOCK=<pathrun in inn.conf>/LOCK.send
47           trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
48           if shlock -p $$ -f ${LOCK} ; then
49               # Do appropriate work.
50           else
51               echo "Locked by `cat ${LOCK}`"
52           fi
53

HISTORY

55       Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews after a
56       description of HDB UUCP locking given by Peter Honeyman, and improved
57       by Berend Reitsma to solve a race condition.  Converted to POD by
58       Julien Elie.
59
60       $Id: shlock.pod 8357 2009-02-27 17:56:00Z iulius $
61
62
63
64INN 2.5.2                         2010-08-11                         SHLOCK(1)
Impressum