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 /doio.c | |
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 'doio.c')
-rw-r--r-- | doio.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1726,6 +1726,8 @@ nothing in the core. * CRTL's emulation of Unix-style signals and kill() */ while (++mark <= sp) { + if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark))) + Perl_croak(aTHX_ "Can't kill a non-numeric process ID"); I32 proc = SvIV(*mark); register unsigned long int __vmssts; APPLY_TAINT_PROPER(); @@ -1750,6 +1752,8 @@ nothing in the core. if (val < 0) { val = -val; while (++mark <= sp) { + if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark))) + Perl_croak(aTHX_ "Can't kill a non-numeric process ID"); const I32 proc = SvIV(*mark); APPLY_TAINT_PROPER(); #ifdef HAS_KILLPG @@ -1762,6 +1766,8 @@ nothing in the core. } else { while (++mark <= sp) { + if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark))) + Perl_croak(aTHX_ "Can't kill a non-numeric process ID"); const I32 proc = SvIV(*mark); APPLY_TAINT_PROPER(); if (PerlProc_kill(proc, val)) |