X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcluster.pl;h=5c3f0fb90a19c83fd59a4ffe5da2838fd90a9697;hb=84fb1f6e7089c24454eeb92bf093e31682db4489;hp=a33e6da5f1a8e76b2907cf8547791702a146cdd9;hpb=3c2ea668af700128a081cc7c17ca93cc685fad37;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index a33e6da5..5c3f0fb9 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -34,11 +34,14 @@ BEGIN { # try to create and lock a lockfile (this isn't atomic but # should do for now $lockfn = "$root/local/cluster.lck"; # lock file name - if (-e $lockfn) { + if (-w $lockfn) { open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!"; my $pid = ; - chomp $pid; - die "Lockfile ($lockfn) and process $pid exist, another cluster running?" if kill 0, $pid; + if ($pid) { + chomp $pid; + die "Lockfile ($lockfn) and process $pid exist, another cluster running?" if kill 0, $pid; + } + unlink $lockfn; close CLLOCK; } open(CLLOCK, ">$lockfn") or die "Can't open Lockfile ($lockfn) $!";