lockf command

Nikos Vassiliadis nvass at gmx.com
Wed Apr 13 13:23:29 UTC 2011


On 4/13/2011 12:08 PM, Bastien Semene wrote:
> I wish that if command #2 can't acquire the lock, lockf exits (exit 0
> would be nice).
> If I set -t 1, lockf is quite what I'm waiting for. But I like to do
> this in a clear way : if it can't acquire the lock it exits, no timeout
> wait.
>
> Am I misunderstanding something ? What should I change ?
>

You should use -t0, something like:
> lab# lockf -t 0 /tmp/lock /bin/csh
> You have mail.
> lab# lockf -t 0 /tmp/lock /bin/csh
> lockf: /tmp/lock: already locked
> lab# echo $?
> 75
> lab#

HTH, Nikos


More information about the freebsd-questions mailing list