Cannot lock a file.

From: Hon Seng Phuah (hsphuah_at_usa.com)
Date: 03/24/04


Date: 24 Mar 2004 00:14:01 -0800

Hi all,

I have following code:

use 5.004'
use Fcntl ':flock';

sub check_file_status
{
   $attempt_lock = 0;
   $max_attempts = 3;
   open(in_file, "$check_in_file_name");
   while (!flock(in_file, LOCK_EX) && $attemp_lock < $max_attempts)
   {
      sleep(5);

   }
close(in_file);
}

I cannot get the exlusive lock for the $check_in_file_name variable
file name. Any idea? How should I correct my mistake?



Relevant Pages