At most 1 running copy

John Summerfield debian at herakles.homelinux.org
Sat Nov 27 13:48:31 UTC 2004


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




More information about the fedora-list mailing list