[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request: Can bash provide some mechanism for locking/unlocki

From: Bob Proulx
Subject: Re: Feature request: Can bash provide some mechanism for locking/unlocking?
Date: Thu, 15 Apr 2010 20:52:23 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]