D. J. Bernstein
UNIX
daemontools

The setlock program

setlock runs another program with a file locked.

Interface

     setlock opts fn child

opts is a series of getopt-style options. fn is a single argument. child consists of one or more arguments.

setlock opens fn for writing (creating it if it does not exist), obtains an exclusive lock on it, and runs child.

Normally the lock disappears when child exits.

Here's the complete story: child is given a descriptor for a locked ofile pointing to the disk file named fn. The lock disappears when this ofile is

Options