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

        Determine all long you want to wait. Say 1 minute, then setup a
small loop and breakout 1 minute into 4 to 6 equal intervals and when your
counter hits 0 then send an email or if interactive, then display to the
user the problem.
my $MyMax = 10;

unless (&shlock("$somedir/.cache.LOCK")) {
    if ( --$MyMax < 1 ) {
         #
         # now print out message after trying, set the max to what you feel
is right
         # either exit or die depending on what you feel is correct.
         #
       print "$main'program_name: cache already running\n" if $verbose;
       exit;
      }else {
       sleep 6; 
      }
 }

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to