Re: At most 1 running copy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 27 November 2004 12:49, Ed Wilts wrote:
> For the record, this snippet works just fine (a per-user lock).
>
> use FileHandle;
> use Fcntl qw(:DEFAULT :flock);
> my $FH = new FileHandle;
> sysopen(FH, "ftphandler.lock", O_RDWR | O_CREAT) or die "can't open
> ftphandler.lock: $!"; flock(FH, LOCK_EX | LOCK_NB) or exit;
> print "running...\n";
> [rest of code here]
> close (FH);
> unlink ("ftphandler.lock");


I nominated /var/run for a reason:-)
It gets cleaned out on a reboot.

Sure locks go, but it's nice to <plonk> the files too.


-- 
Cheers
John


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux