On Wed, 07 Apr 2004 14:50:54 -0500 "JupiterHost.Net" <[EMAIL PROTECTED]> wrote:
> So flock(FH, LOCK_EX | LOCK_NB) then? Yes. > So: > my $rc = flock(FH, LOCK_EX | LOCK_NB); > > if($rc == 0) { warn "rats! Exclusive lock not granted, oh well..."; } > if(!defined $rc) { die "Could not get lock no how mr flock guy!"; } > > or > > if(!$rc) { $! =~ m/No Lock/ ? warn "not exclusive but locked - $!" : > die "no lock - $!"; } If $rc is zero, you likely did not get the lock. You might have a zero return code with a parameter error, in which case $! is set to a different message. Here is a little script I used to test all this. I ran the script and backgrounded it on my Linux box. I then ran a second copy to see what the return code and $! are when the lock is grabbed by the first process. #!/usr/bin/perl -w use strict; use Fcntl ':flock'; open(ZZZ, ">zzz"); my $ret = flock(ZZZ, LOCK_EX | LOCK_NB); print "$ret $!\n"; sleep 60; > Thanks for the info BTW I really appreciate it! :) No problem. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>