Clark J. Wang wrote: > Bob Proulx wrote: > > There is also 'lockfile' distributed with 'procmail'. > > By using `lockfile' we must make sure that our script will not crash and > the file is unlocked when the script exits.
True. That is true of any of the file based locking methods. And advantage to the flock/lockf based methods such as flock(1). But I almost always have cleanup traps for other reasons and incorporate the cleanup there to ensure that the lockfile is removed by the creating process when it exits. As far as needing to make sure that your script doesn't crash, well, don't you need to do that anyway? :-) > Although it provides timeout mechanism it's still not so convinient. Beware of the timeout. That isn't safe and may violate your mutual exclusion section. Actually it almost certainly will violate it. Bob