1 .TH "locking" 1 "11 May 2003" "Mark Wooding" "Toys"
3 locking \- run a program with a lock held
19 program opens and locks
21 while it runs some program
23 This is handy in shell scripts and (particularly) crontab entries. It
24 was initially written to ensure that news fetches only occurred if the
25 previous one had completed.
29 locking. It will not leave stale locks lying around: the lock is
34 program itself quits for any reason.
36 The following options are supported:
39 Write a full help message to stdout, and exit zero.
42 Write the version number to stdout, and exit zero.
45 Write a brief usage message to stdout, and exit zero.
47 .BR "\-c, \-\-" [ "no\-" ] "create"
50 if it doesn't already exist. The file is created with mode 666 as
51 modified by the process's umask in the usual way. This is the default
52 behaviour. The options
58 to fail if the file does not already exist.
60 .BR "\-f, \-\-" [ "no\-" ] "fail"
61 Fail (report an error and exit nonzero) if
63 is already locked. The default behaviour is to exit successfully
67 .BR "\-w, \-\-" [ "no\-" ] "wait"
70 to become available. The default behaviour is to give up immediately.
72 .BR "\-x, \-\-" [ "no\-" ] "exclusive"
73 Obtain an exclusive lock on the file. This is the default. The options
77 obtain a non-exclusive lock on the file instead.
79 .BI "\-p, \-\-program=" realprog
84 as its first argument. The default behaviour is to run
87 .BI "\-t, \-\-timeout=" time
90 (an integer, optionally followed by
96 for days, hours, minutes or seconds, respectively) for the lock to
97 become available, and then give up. This only makes sense with the
99 option, so that is turned on automatically.
103 program messes with alarms. It tries to put them back the way it found
104 them, but may get things wrong.
107 Mark Wooding, <mdw@nsict.org>