--- Dave Anderson <[EMAIL PROTECTED]> wrote:

> I started off with what I thought was a simple
> question, but googling,
> searching mailing list archives, reading man pages,
> and testing hasn't
> turned up anything I'm happy with and has raised
> some new issues...
> 
> In a past life, on a non-Unix system, I was able to
> set up simple and
> effective mutual exclusion in the equivalent of
> shell scripts by
> opening a file for write access (which created an
> exclusive lock on the
> file) at the start of the protected section and not
> closing it until
> the end of that section.  This had no race
> conditions and had no
> problem of stale locks since the lock was
> automatically released if the
> process holding it terminated abnormally.
.......

> 
> Thanks in advance for any advice,
> 
>       Dave
> 
> -- 
> Dave Anderson
> <[EMAIL PROTECTED]>
> 
> 

One can use mkdir call for mutual exclusion
(instead of files). In the directory a file with 
process id and it's args should be written.

The contesting process will try to make the directory 
and if this fails will check the process that
locked the directory. If it does not exsist,
just remove the lock directory and start mkdir again
to lock..
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to