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
19       A Perl wrapper around shlock can be used via the "INN::Utils::Shlock"
20       module.
21

OPTIONS

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

EXAMPLES

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

HISTORY

58       Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews after a
59       description of HDB UUCP locking given by Peter Honeyman, and improved
60       by Berend Reitsma to solve a race condition.  Converted to POD by
61       Julien Elie.
62

SEE ALSO

64       INN::Utils::Shlock(3pm).
65
66
67
68INN 2.6.5                         2022-01-23                         SHLOCK(1)
Impressum