} elsif (defined $otherpid && $otherpid) {
return if $$ == $otherpid; # should never happen
$CPAN::Frontend->mywarn(
qq{
There seems to be running another CPAN process (pid $otherpid). Contacting...
});
if (kill 0, $otherpid or $!{EPERM}) {
$CPAN::Frontend->mywarn(qq{Other job is running.\n});
my($ans) =
CPAN::Shell::colorable_makemaker_prompt
(qq{Shall I try to run in degraded }.
qq{mode? (Y/n)},"y");
if ($ans =~ /^y/i) {
$CPAN::Frontend->mywarn("Running in degraded mode (experimental).
Please report if something unexpected happens\n");
$RUN_DEGRADED = 1;
for ($CPAN::Config) {
# XXX
# $_->{build_dir_reuse} = 0; # 2006-11-17 akoenig Why was that?
$_->{commandnumber_in_prompt} = 0; # visibility
$_->{histfile} = ""; # who should win otherwise?
$_->{cache_metadata} = 0; # better would be a lock?
$_->{use_sqlite} = 0; # better would be a write lock!
}
} else {
$CPAN::Frontend->mydie("
You may want to kill the other job and delete the lockfile. On UNIX try:
kill $otherpid
rm $lockfile
");
}
} elsif (-w $lockfile) {
my($ans) =
CPAN::Shell::colorable_makemaker_prompt
(qq{Other job not responding. Shall I overwrite }.
qq{the lockfile '$lockfile'? (Y/n)},"y");
$CPAN::Frontend->myexit("Ok, bye\n")
unless $ans =~ /^y/i;
} else {
Carp::croak(
qq{Lockfile '$lockfile' not writeable by you. }.
qq{Cannot proceed.\n}.
qq{ On UNIX try:\n}.
qq{ rm '$lockfile'\n}.
qq{ and then rerun us.\n}
);
}
} else {
$CPAN::Frontend->mydie(sprintf("CPAN.pm panic: Found invalid lockfile ".
"'$lockfile', please remove. Cannot proceed.\n"));
}
}
my $dotcpan = $CPAN::Config->{cpan_home};
eval { File::Path::mkpath($dotcpan);};
if ($@) {
# A special case at least for Jarkko.
my $firsterror = $@;
my $seconderror;
my $symlinkcpan;
if (-l $dotcpan) {
$symlinkcpan = readlink $dotcpan;
die "readlink $dotcpan failed: $!" unless defined $symlinkcpan;
eval { File::Path::mkpath($symlinkcpan); };
if ($@) {
$seconderror = $@;
} else {
$CPAN::Frontend->mywarn(qq{
Working directory $symlinkcpan created.
});
}
}
unless (-d $dotcpan) {
my $mess = qq{
Your configuration suggests "$dotcpan" as your
CPAN.pm working directory. I could not create this directory due
to this error: $firsterror\n};
$mess .= qq{
As "$dotcpan" is a symlink to "$symlinkcpan",
I tried to create that, but I failed with this error: $seconderror
} if $seconderror;
$mess .= qq{
Please make sure the directory exists and is writable.
};
$CPAN::Frontend->mywarn($mess);
return suggest_myconfig;
}
} # $@ after eval mkpath $dotcpan
if (0) { # to test what happens when a race condition occurs
for (reverse 1..10) {
print $_, "\n";
sleep 1;
}
}
# locking
if (!$RUN_DEGRADED && !$self->{LOCKFH}) {
my $fh;
unless ($fh = FileHandle->new("+>>$lockfile")) {
if ($! =~ /Permission/) {
$CPAN::Frontend->mywarn(qq{
=12= |