--- Bart Lateur <[EMAIL PROTECTED]> wrote:

>
> Here's a draft, I haven't thoroughly tested it.
>
>       use Fcntl;
>       {
>           my @lockfiles;
>           END {
>               foreach(@lockfiles) { unlink }  # for 5.004
>           }
>           sub lockFile ($) {
>           #Create a lock file for the file passed as a parameter.
>               my $lockfile = shift() . '.lock';
>               my $t0 = time;
>               local *LOCK;
>               until(sysopen LOCK, $lockfile,
>                 O_CREAT|O_TRUNC|O_EXCL|O_WRONLY) {
>                   die "Too many loops" if time-$t0 > 10;
>                   select undef, undef, undef, 0.1;
>               }
>               push @lockfiles, $lockfile;
>               print LOCK $$;
>               close LOCK;
>           }
>       }
>
> --
>       Bart.

Bart,

Thank you for the pointers. Unfortunately, the wooshing sound you just heard
was that code passing over my head at high speed. As I do not like
'cut-and-paste' programming, I am unwilling to use your code when I don't
understand much of it. =8O)

How much danger am I in with the script as it stands, given that this function
gets used quite rarely, perhaps 2/3 times a week (which is a little
distressing, given that it is part of our quote request system)?

> You also need to delete the lockfile when you're through. That's
> dangerous: if your script dies, the lockfile won't be deleted. Unless
> you take care of that...

If a lock file is left behind, it gets deleted next time the sub is called. I
only use it to access one file that contains an index number. In retrospect,
this method doesn't really suit Lantz's application. That will teach me to
think before I type.

Thanks,

Richard (chagrined).


=====
Team Artonomy
Drawing Business
http://www.team-artonomy.com/
http://www.drawingbusiness.com/

The #1 Illustration studio on Google.
Listed on Wow Web Designs, http://www.wowwebdesigns.com/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Reply via email to