* 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();
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
}
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))
use lib qw(t/lib);
use Test::More tests => 1;
-eval { kill 0, $^X };
+eval { `$^X -e1` };
like( $@, '/^Insecure dependency/', '-T honored' );
my $warnings = '';
{
local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
- kill 0, $^X;
+ `$^X -e1`;
}
like( $warnings, '/^Insecure dependency/', '-t honored' );
as documented, and as does C<-I> when specified on the command-line.
(Renée Bäcker)
+=item C<kill> is now fatal when called on non-numeric process identifiers
+
+Previously, an 'undef' process identifier would be interpreted as a request to
+kill process "0", which would terminate the current process group on POSIX
+systems. Since process identifiers are always integers, killing a non-numeric
+process is now fatal.
+
=back
=head1 New or Changed Diagnostics
situation typically indicates that the parent program under which Perl
may be running (e.g. cron) is being very careless.
+=item Can't kill a non-numeric process ID
+
+(F) Process identifiers must be (signed) integers. It is a fatal error to
+attempt to kill() an undefined, empty-string or otherwise non-numeric
+process identifier.
+
=item Can't "last" outside a loop block
(F) A "last" statement was executed to break out of the current block,
alive (even if only as a zombie) and hasn't changed its UID. See
L<perlport> for notes on the portability of this construct.
-Unlike in the shell, if SIGNAL is negative, it kills
-process groups instead of processes. (On System V, a negative I<PROCESS>
-number will also kill process groups, but that's not portable.) That
-means you usually want to use positive not negative signals. You may also
-use a signal name in quotes.
+Unlike in the shell, if SIGNAL is negative, it kills process groups instead
+of processes. That means you usually want to use positive not negative signals.
+You may also use a signal name in quotes.
+
+The behavior of kill when a I<PROCESS> number is zero or negative depends on
+the operating system. For example, on POSIX-conforming systems, zero will
+signal the current process group and -1 will signal all processes.
See L<perlipc/"Signals"> for more details.
use strict;
-plan tests => 2;
+plan tests => 5;
ok( kill(0, $$), 'kill(0, $pid) returns true if $pid exists' );
# 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");
+}
+