Subject: | noise about uninitialized values if run under -w |
Date: | Wed, 04 Nov 2015 20:01:58 +1000 |
To: | bug-Proc-PID-File [...] rt.cpan.org |
From: | Alexander Zangerl <az [...] snafu.priv.at> |
this is a forward of debian bug #803442, which lives over there:
http://bugs.debian.org/803442
the issue is that if you use proc::pid::file with use warnings,
then you get lots of "uninitialized values" warnings.
e.g.:
# perl -MProc::PID::File -wE'die if Proc::PID::File->running({dir => "."})'
Use of uninitialized value $fh in pattern match (m//) at
/usr/share/perl5/Proc/PID/File.pm line 288.
this is because the read from <$fh> is not checked for content but run
through the regex immediately. on newly created pid files it is thus undef.
the fix is trivial:
--- a/File.pm
+++ b/File.pm
@@ -285,7 +285,8 @@ sub read {
|| die qq/Cannot open pid file "$self->{path}": $!\n/;
flock($fh, LOCK_EX | LOCK_NB)
|| die qq/pid "$self->{path}" already locked: $!\n/;
- my ($pid) = <$fh> =~ /^(\d+)/;
+ my $maybe = <$fh>;
+ my ($pid) = $maybe =~ /^(\d+)/ if (defined $maybe);
close $fh if @_ == 1;
$self->debug("read(\"$self->{path}\") = " . ($pid || ""));
regards
az
--
Alexander Zangerl + GPG Key 0xB963BD5F + http://snafu.priv.at/
Es ist nichts so absurd, daß Gläubige es nicht glaubten.
Oder Beamte täten. -- Arno Schmidt
Message body not shown because it is not plain text.