On 6/11/07, oryann9 <[EMAIL PROTECTED]> wrote:
snip
If you use LOCK_NB and are refused a LOCK_SH, then you
know that someone else has a LOCK_EX and is updating
the file. If you are refused a LOCK_EX, then someone
holds either a LOCK_SH or a LOCK_EX, so you shouldn't
try to update the file.
snip
In this code:
BEGIN {
use Fcntl ':flock';
open( DATA, qq(C\:\\temp\\file.txt) )
or die "file handle was not opened: $!";
for my $foo () {
print $foo;
}
flock DATA, LOCK_EX | LOCK_NB or exit 0;
}
Is there anything more one could add to this statement
from the Co
use Fcntl qw(:flock);
until(flock $fh, LOCK_EX|LOCK_NB)
{
$lockwait++;
if($lockwait == 10)
{
print STDERR "timed out waiting for lock\n";
exit 1;
}
sleep 1;
}
this will do a non-blocking attempt to get the lock, and try 10 t
look in to the alarm() function
perldoc -f alarm
+Pete
--
[EMAIL PROTECTED]
;;($_='Yw_xUabcdtefgdijktljkotiersjkUzxT
yvlkbfdtcierstajogvPruntRshackRJelov')=~
y&/RTUv;wxYz$&/ ~'/;$=();$&&&eval&&print
<[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I'
Hi,
I'm trying to lock a file exclusively so that other process has no access
to it
I'm using:
flock($fh,2);
It does work, and in the second process I use the same procedure.
The problem is that I can't set a time limit for the lock.
I want to try to capture the lock, and if unsuccessful, the