On Fri, 30 Oct 2015 09:00:31 +0000, Damyan Ivanov writes:
> $ 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.

i'm uploading a fixed version in the next few minutes.

please note that your patch is broken:

>--- 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 $pid = <$fh>;
>+        $pid =~ /^(\d+)/ if defined($pid);
>       close $fh if @_ == 1;

with your code $pid is never modified and contains whatever line
was read from $fh, including whitespace, other
trailing gunk and possibly a final newline.

you seem to have missed the operator precedence in the original
code; the =~ binds stronger, so the fh read result is run through the
regex first and the result of that ends in $pid. in your variant
pid is read, but the following regex-match is a nop without consequences.

regards
az


-- 
Alexander Zangerl + GPG Key 0xB963BD5F + http://snafu.priv.at/
I keep six honest serving-men - (They taught me all I knew);
Their names are What and Why and When - And How and Where and Who
 -- Kipling

Attachment: signature.asc
Description: Digital Signature

Reply via email to