setlock8
Runs another program with a file locked.
Usage
setlock [-nNxX]
fn
child
Overview
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
o
|
closed by all the processes that have descriptors for it or |
|---|---|
o
|
explicitly unlocked. |
Options
-
-n -
No delay. If fn is locked by another process,
setlockgives up.
-
-N -
(Default.) Delay. If fn is locked by another process,
setlockwaits until it can obtain a new lock.
-
-x -
If fn cannot be opened (or created) or locked,
setlockexits zero.
-
-X -
(Default.) If fn cannot be opened (or created) or locked,
setlockprints an error message and exits nonzero.
Releases
Unchanged in 9 releases since Debian 5.0 (Lenny).