Deb wrote:
>
> Hi,
>
> I need to modify some code that check for the existance of a lockfile:
>
> unless (&shlock("$somedir/.cache.LOCK")) {
> print "$main'program_name: cache already running\n" if $verbose;
> exit;
> }
>
> I don't want to "exit" if I find the lock there. What I need to do is
> back off for a short period of time (a few seconds?) then try again, until
> the lockfile is gone.
>
> I'm not sure what might be the best way to approach this. I'm not comfy
> with an indefinite loop, where if there is some problem removing the lockfile,
> my program would wait forever. I'd rather try for a few minutes, then exit
> with some error.
Maybe something like this will work for you?
my $start = time;
my $waitfor = 10 * 60; # 10 minutes
while ( -e "$somedir/.cache.LOCK" ) {
sleep 1;
last if time - $start > $waitfor;
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]