Hi, I'm trying to get flock to behave consistently between IRIX,Solaris and Linux (2.4.x).
When I run the following Perl Program, IRIX and Solaris allows the Shared lock (and doesn't execute the inside of the while loop) Where as, Linux denies the Shared lock with "Resource temporarily unavailable" and terminates the program when it tries 11 times.Which is what I expect. Why the difference? Thx, JSA #!/usr/bin/perl use FileHandle (); use Fcntl; use strict; my $tries = 0; my $Lockfile="/tmp/my..LCK"; # For flock()... my %LOCK = (SH=>1, EX=>2, NB=>4, UN=>8); # Open file to be used as lockfile (unlink it first to force new inode): unlink $Lockfile; my $selfLOCK = FileHandle->new("+>$Lockfile") or die "open $Lockfile: $!"; $selfLOCK->autoflush(1); flock($selfLOCK, $LOCK{EX}) or die "flock: $!"; my $SecondFH = FileHandle->new("+>$Lockfile") or die "open $Lockfile: $!"; # Should fail, until EX lock is realeased: # Based on manpage : # A single file may not simultaneously have both shared and # exclusive locks. while (!flock($SecondFH, $LOCK{SH}|$LOCK{NB})) { print "Try $tries; still going... $! \n"; die if (++$tries > 10); sleep 2; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]