Changeset View
Changeset View
Standalone View
Standalone View
lockf/lockf.1
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
.Nm | .Nm | ||||
to operate silently. | to operate silently. | ||||
Failure to acquire the lock is indicated only in the exit status. | Failure to acquire the lock is indicated only in the exit status. | ||||
.It Fl n | .It Fl n | ||||
Causes | Causes | ||||
.Nm | .Nm | ||||
to fail if the specified lock | to fail if the specified lock | ||||
.Ar file | .Ar file | ||||
does not exist. If | does not exist. | ||||
If | |||||
.Fl n | .Fl n | ||||
is not specified, | is not specified, | ||||
.Nm | .Nm | ||||
will create | will create | ||||
.Ar file | .Ar file | ||||
if necessary. | if necessary. | ||||
.It Fl t Ar seconds | .It Fl t Ar seconds | ||||
Specifies a timeout for waiting for the lock. | Specifies a timeout for waiting for the lock. | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
.Xr fork 2 ) | .Xr fork 2 ) | ||||
failed unexpectedly. | failed unexpectedly. | ||||
.It Dv EX_SOFTWARE | .It Dv EX_SOFTWARE | ||||
The | The | ||||
.Ar command | .Ar command | ||||
did not exit normally, | did not exit normally, | ||||
but may have been signaled or stopped. | but may have been signaled or stopped. | ||||
.El | .El | ||||
.Sh EXAMPLES | |||||
The first job takes a lock and sleeps for 5 seconds in the background. | |||||
The second job tries to get the lock and timeouts after 1 second (PID numbers | |||||
will differ): | |||||
.Bd -literal -offset indent | |||||
$ lockf mylock sleep 5 & lockf -t 1 mylock echo "Success" | |||||
[1] 94410 | |||||
lockf: mylock: already locked | |||||
.Ed | |||||
.Pp | |||||
The first job takes a lock and sleeps for 1 second in the background. | |||||
bcr: s/sleesp/sleeps/ | |||||
Done Inline ActionsThis one hurts. I tend to do this before submitting: svn diff | aspell --lang=en list and then review the list. Clearly I didn't spot this one, but is there a better way of spell checking the changes? fernape: This one hurts.
I tend to do this before submitting: `svn diff | aspell --lang=en list` and… | |||||
Not Done Inline ActionsMaybe ispell? But I have my own internal spell checking, which is also not perfect and misses typos occasionally. Don't worry, that's why we have reviews where more eyeballs help catch these sort of things. ;-) bcr: Maybe ispell? But I have my own internal spell checking, which is also not perfect and misses… | |||||
The second job waits up to 5 seconds to take the lock and echoes the message on | |||||
success (PID numbers will differ): | |||||
.Bd -literal -offset indent | |||||
$ lockf mylock sleep 1 & lockf -t 5 mylock echo "Success" | |||||
Done Inline ActionsHow about "Success" instead of "Hello" ? bcr: How about "Success" instead of "Hello" ? | |||||
[1] 19995 | |||||
Success | |||||
[1]+ Done lockf mylock sleep 1 | |||||
.Ed | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr flock 2 , | .Xr flock 2 , | ||||
.Xr lockf 3 , | .Xr lockf 3 , | ||||
.Xr sysexits 3 | .Xr sysexits 3 | ||||
.Sh HISTORY | .Sh HISTORY | ||||
A | A | ||||
.Nm | .Nm | ||||
utility first appeared in | utility first appeared in | ||||
.Fx 2.2 . | .Fx 2.2 . | ||||
.Sh AUTHORS | .Sh AUTHORS | ||||
.An John Polstra Aq Mt jdp@polstra.com | .An John Polstra Aq Mt jdp@polstra.com |
s/sleesp/sleeps/