in reply to Re: use flock() to determine if other script is running
in thread use flock() to determine if other script is running

That won't work... two processes can both look to notice a file doesn't exist, then both "create" it.

To properly lock, you must have an atomic "test-and-set" operation that is uninterruptable by another process.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: Re: use flock() to determine if other script is running

Replies are listed 'Best First'.
Re: •Re: Re: use flock() to determine if other script is running
by tcf22 (Priest) on Aug 21, 2003 at 06:46 UTC
    I realize that there is a mutual exclusion issue. Looking at the original post, he asked how to tell if the other process was running. Perhaps a better question would have been, how can I check if another process is in a critical section of the code. Normally with threads, you can use a semaphore. I guess I didn't look enough into the question, I just answered the one that was posed.
Re: •Re: Re: use flock() to determine if other script is running
by Red_Dragon (Beadle) on Aug 21, 2003 at 15:32 UTC
    Thanks for the caveat.