If the number of retries expires before all files have been created, lockfile returns failure and removes all the files it created up till that point.
The return value of lockfile can be easily inverted by specifying -! as an argument (comes in handy in shell scripts).
All flags can be specified anywhere on the command line, they will be processed when encountered. The command line is simply parsed from left to right.
All files created by lockfile will have access permission 0, and therefore will have to be removed with rm -f.
If you specify a locktimeout then a lockfile will be removed by force after locktimeout seconds have passed since the lockfile was last modified/created (most probably by some other program that unexpectedly died a long time ago, and hence could not clean up any leftover lockfiles). Lockfile is clock skew immune. After a lockfile has been removed by force, a suspension of suspend seconds (defaults to 16) is taken into account, in order to prevent the inadvertent immediate removal of any newly created lockfile by another program (compare SUSPEND in procmail(1)).
. . . lockfile important.lock . . . access_"important"_to_your_hearts_content . . . rm -f important.lock . . .Now if all the scripts that access "important" follow this guideline, you will be assured that at most one script will be executing between the `lockfile' and the `rm' commands.
Multiple -! flags will toggle the return status.
Since flags can occur anywhere on the command line, any filename starting with a '-' has to be preceded by './'.
The number of retries will not be reset when any following file is being created (i.e. they are simply used up). It can, however, be reset by specifying after every file on the command line.
Although files with any name can be used as lockfiles, it is common practice to use the extension `.lock' to lock mailfolders (it is appended to the mailfolder name). In case one does not want to have to worry about too long filenames and does not have to conform to any other lockfilename convention, then an excellent way to generate a lockfilename corresponding to some already existing file is by taking the prefix `lock.' and appending the i-node number of the file which is to be locked. This program is part of the procmail mail-processing-package (v3.10 1994/10/31) available at your nearest USENET comp.sources.misc archive, or at ftp.informatik.rwth-aachen.de as pub/packages/procmail/procmail.tar.gz. There exists a mailinglist for questions relating to any program in the procmail package:
procmail@informatik.rwth-aachen.deStephen R. van den Berg at RWTH-Aachen, Germany berg@pool.informatik.rwth-aachen.defor submitting questions/answers.procmail-request@informatik.rwth-aachen.defor subscription requests.