Re: flock, fcntl, lockf?
On Tue, 15 Jan 2008 10:33:49 +0100, Vincent Lefevre wrote:
> On 2008-01-14 23:50:35 +0000, Hendrik Boom wrote:
> I tend to use fcntl because it is NFS safe and when the program dies
> for whatever reason (even kill -9, which is not trappable to explicitly
> remove the lock), the lock disappears. Another very important advantage
> (this is sometimes necessary) is that NFS cache problems are avoided on
> the locked file. But depending on the context, one doesn't always want
> the lock to disappear if the program couldn't do the necessary clean-up
> first (there are other ways to deal with that, though).
Thanks. It looks as if I'll be using fcntl locking. And I believe that
lockf is implemented as a front end to fcntl, from what I've heard,
though as far as I know its specification doesn't require it to be
implemented this was.
Someone has asked me if doing it this way is compatible with Windows. I
have no idea. I haven't programmed for Windows in ages.
> I also use symlink locking, which is also NFS safe, mainly in my shell
> scripts, because this is quite easy in this context. And one can put
> interesting information in the symlink contents (the symlink doesn't
> have to point to a real file). See what Firefox does for instance (the
> lock is in the profile).
What is symlink locking? If firefox uses it that probably accounts
for the weird links I see around now and then. It does seem to
unlock upon killall, too. Betcha it won't work in Windows :-)
> Vincent Lefèvre <firstname.lastname@example.org> - Web: <http://www.vinc17.org/>
> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
> Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)