On Fri, Apr 16, 2010 at 12:57 AM, Bob Proulx <b...@proulx.com> wrote:

> Eric Blake wrote:
> > Clark J. Wang wrote:
> > > In C code I can use lockf(), flock(), semaphore and mutex for locking /
> > > unlocking. Can bash provide some similar mechanisms?
> >
> > man 1 flock
> >
> > If necessary, you may need to install:
> > ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/
>
> 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. Although it provides timeout
mechanism it's still not so convinient.

>
>  http://www.procmail.org/
>
> I tend to use 'mkdir' when I need a semaphore in a shell script.
>
> Bob
>

Reply via email to