Dirrty Hax0r in Perl 5.12 Pid.pm for varnish-agent

Right, so I am not particularly proud of this but again, more of a note to self than anything. Secondly, I am most certainly not a Perl expert. This little hack should probably never be used or put into any production Mac setup. If you know of a proper fix, please do let me know.

Lastly, this is varnish-agent and not varnish-agent2. The former is written in Perl while the latter is written in C and uses Varnish API directly.

OK! Now that the disclaimer is out of the way, onward with the dodgy! So when running varnish-agent on OSX 10.8.2, one may encounter the following issue:

Can't kill a non-numeric process ID at /Library/Perl/5.12/File/Pid.pm line 124.

The quick fix is proposed here involves adding this line to the the Pid.pm file on line 124.

return undef unless $pid > 0;

So your subroutine in Pid.pm will end up looking more like this.

sub running {
   my $self = shift;
   my $pid  = $self->_get_pid_from_file;
   return undef unless $pid > 0;
   return   kill(0, $pid)
      ? $pid
      : undef;
}

About these ads

2 thoughts on “Dirrty Hax0r in Perl 5.12 Pid.pm for varnish-agent

  1. I am a Perl expert. This has nothing to do with Perl 5.12 itself because File-PID is a 3rd party CPAN module.

    The File-PID distribution is unmaintained and buggy, see reviews at “http://cpanratings.perl.org/dist/File-Pid”. Your bug is a long-known one, discussion/patch is available from “https://rt.cpan.org/Ticket/Display.html?id=18960″. It is a mistake of varnish-agent to depend on File-PID. The authors should change their code and depend on a better PID handling module. If you care about varnish-agent, report this upstream so it can be taken care of properly; writing in your blog accomplishes nothing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s