develooper Front page | perl.perl5.porters | Postings from June 2010

Re: [perl #75812] kill $1 broken in 5.12.1

Thread Previous
From:
Eric Brine
Date:
June 17, 2010 16:00
Subject:
Re: [perl #75812] kill $1 broken in 5.12.1
Message ID:
AANLkTikPDI4JI2I3mV6EcJlJoPVjRD06PQQeIvlBZZT_@mail.gmail.com
On Wed, Jun 16, 2010 at 4:08 PM, Todd Rinaldo <perlbug-followup@perl.org>wrote:

> # New Ticket Created by  Todd Rinaldo
> # Please include the string:  [perl #75812]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75812 >
>
>
> We've discovered that this snippet will break in perl 5.12
>
> my $pid = "12345  ";
> if($pid =~ m/(\d+)/) {
>        kill 9, $1;
> }
>
> it dies with this message:
> Can't kill a non-numeric process ID at test.pl line 7.
>

The fix is simply the following x3, I think:

+SvGETMAGIC(*mark);
 if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark)))
     Perl_croak(aTHX_ "Can't kill a non-numeric process ID");
-proc = SvIV(*mark);
+proc = SvIV_nomg(*mark);

Clean test:

'abc' =~ /(.*)/;  # Make sure PV has non-number.
my $x = $1;
$pid =~ /(.*)/;
kill TERM => $1;

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About