[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request: Can bash provide some mechanism for locking/unlock
From: |
Clark J. Wang |
Subject: |
Re: Feature request: Can bash provide some mechanism for locking/unlocking? |
Date: |
Fri, 16 Apr 2010 09:31:29 +0800 |
On Fri, Apr 16, 2010 at 12:57 AM, Bob Proulx <bob@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
>
Re: Feature request: Can bash provide some mechanism for locking/unlocking?, Jan Schampera, 2010/04/15