in reply to Re: Ensuring only one copy of a perl script is running at a time
in thread Ensuring only one copy of a perl script is running at a time
That's wrong. It suffers from a race condition.
+===============================+===============================+ | Process 1 | Process 2 | +===============================+===============================+ | open the status file | | T | read the status (status is 1) | | i +-------------------------------+-------------------------------+ m | | open the status file | e | | read the status (status is 1) | | | | write 2 to the status file | | | | proceed | | +-------------------------------+-------------------------------+ v | write 2 to the status file | | | proceed | | +===============================+===============================+
If you use flock, then it's just an extention of what the OP posted.
( Oops! Seems like tye posted something similar when I was writing this node. )
|
---|
Replies are listed 'Best First'. | |
---|---|
A reply falls below the community's threshold of quality. You may see it by logging in. |
In Section
Seekers of Perl Wisdom