From: Steve Hay Date: Wed, 18 Apr 2007 08:40:42 +0000 (+0000) Subject: Add a test for the bug fixed by #30970 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b84cdbe2ce63ed4f4e041a1277f4da249e158af9;p=p5sagit%2Fp5-mst-13.2.git Add a test for the bug fixed by #30970 p4raw-id: //depot/perl@30973 --- diff --git a/MANIFEST b/MANIFEST index 21e9531..31aac08 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3686,6 +3686,7 @@ t/op/inc.t See if inc/dec of integers near 32 bit limit work t/op/index.t See if index works t/op/int.t See if int works t/op/join.t See if join works +t/op/kill0.t See if kill(0, $pid) works t/op/lc.t See if lc, uc, lcfirst, ucfirst, quotemeta work t/op/lc_user.t See if user-defined lc et alia work t/op/length.t See if length works diff --git a/t/op/kill0.t b/t/op/kill0.t new file mode 100644 index 0000000..063c388 --- /dev/null +++ b/t/op/kill0.t @@ -0,0 +1,31 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} + +BEGIN { + if ($^O eq 'riscos') { + skip_all("kill() not implemented on this platform"); + } +} + +use strict; + +plan tests => 2; + +ok( kill(0, $$), 'kill(0, $pid) returns true if $pid exists' ); + +# It's not easy to come up with an individual PID that is known not to exist, +# so just check that at least some PIDs in a large range are reported not to +# exist. +my $count = 0; +my $total = 30_000; +for my $pid (1 .. $total) { + ++$count if kill(0, $pid); +} +# 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' );