You can use sleep to pause and then use a counter to pause for a max number of seconds. my $max='500'; my $time=0; unless ((&shlock("$somedir/.cache.LOCK")) or ($time==$max)) { print "$main'program_name: cache already running\n" if $verbose; sleep 5; $time+=5; } die "Couldn't get the lock" if ($time==$max);
On Thu, 20 Feb 2003, 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. > > Any pearls of wisdom out there? I could use a boost... > > Thanks, > > deb > > > -- Those responsible for the signature have been sacked. Pete Emerson WSS AM&T Yale University -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]