perldoc -f flock says

 "If LOCK_NB is bitwise-or'ed with LOCK_SH or LOCK_EX then "flock" will
 return immediately rather than blocking waiting for the lock (check the
 return status to see if you got it)."

So that would mean:

use Fcntl ':flock';

flock(FH, LOCK_EX || LOCK_NB) or die "Lock failed $!";
...
flock FH, LOCK_UN;

correct?

If so, do the numeric values work the same way?

flock(FH, 1 || 4) or die "Lock failed $!";
...
flock FH, 8;

correct?

If you do the (LOCK_EX || LOCK_NB) or (1 || 4) is the return code different depending on the type of lock received?

IE
 my $rc = flock(FH, LOCK_EX || LOCK_NB);
 if($rc == 4) { warn "rats! Exclusive lock not granted, oh well..."; }
 if(!$rc) { die "Could not get lock no how mr flock guy!"; }


TIA


Lee.M - JupiterHost.Net

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to