diff options
author | David Golden <dagolden@cpan.org> | 2009-07-08 13:28:54 -0400 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-07-09 15:33:40 +0200 |
commit | e2c0f81f627951896aca833460887e6e8f20aba6 (patch) | |
tree | 48420005abab0f5a8a1ac5404d4c53fe45f79fd8 /t | |
parent | 32878f30ba1216461c8932946f0868cda9920d62 (diff) | |
download | perl-e2c0f81f627951896aca833460887e6e8f20aba6.tar.gz |
Make kill() fatal for non-numeric pids
As the debate over the best way to deal with floating point
pids stalled, this is just for non-numeric, which at least
squashes the bug even if it's not the Platonic ideal for
everyone.
It also doesn't address overloaded objects that might not have
IV, NV or PV appropriately set, but the approach mirrors what is
done elsewhere in doio.c so I recommend applying this patch now and
fixing the problem of overloaded objects at some other time when
it can be done more globally, either through an improvement or
replacement of looks_like_number
Also updated POD for kill when process is 0 or negative and
fixed Test-Harness tests that used kill with a string pid.
(Test-Harness test fix also submitted upstream)
Diffstat (limited to 't')
-rw-r--r-- | t/op/kill0.t | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/t/op/kill0.t b/t/op/kill0.t index 063c38897b..eadf15dc36 100644 --- a/t/op/kill0.t +++ b/t/op/kill0.t @@ -14,7 +14,7 @@ BEGIN { use strict; -plan tests => 2; +plan tests => 5; ok( kill(0, $$), 'kill(0, $pid) returns true if $pid exists' ); @@ -29,3 +29,17 @@ for my $pid (1 .. $total) { # It is highly unlikely that all of the above PIDs are genuinely in use, # so $count should be less than $total. ok( $count < $total, 'kill(0, $pid) returns false if $pid does not exist' ); + +# Verify that trying to kill a non-numeric PID is fatal +my @bad_pids = ( + [ undef , 'undef' ], + [ '' , 'empty string' ], + [ 'abcd', 'alphabetic' ], +); + +for my $case ( @bad_pids ) { + my ($pid, $name) = @$case; + eval { kill 0, $pid }; + like( $@, qr/^Can't kill a non-numeric process ID/, "dies killing $name pid"); +} + |