You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2004/11/29 20:22:48 UTC
svn commit: r106943 - /perl/modperl/trunk/t/response/TestPerl/signals.pm
Author: stas
Date: Mon Nov 29 11:22:47 2004
New Revision: 106943
URL: http://svn.apache.org/viewcvs?view=rev&rev=106943
Log:
perl signals tests
Added:
perl/modperl/trunk/t/response/TestPerl/signals.pm
Added: perl/modperl/trunk/t/response/TestPerl/signals.pm
Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestPerl/signals.pm?view=auto&rev=106943
==============================================================================
--- (empty file)
+++ perl/modperl/trunk/t/response/TestPerl/signals.pm Mon Nov 29 11:22:47 2004
@@ -0,0 +1,62 @@
+package TestPerl::signals;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache::MPM ();
+
+use POSIX qw(SIGALRM);
+
+use Apache::Const -compile => qw(OK);
+
+my $mpm = lc Apache::MPM->show;
+
+# XXX: ALRM sighandler works with prefork, but it doesn't work with
+# worker (others?)
+
+sub handler {
+ my $r = shift;
+
+ plan $r, tests => 2,
+ need { "works for prefork" => ($mpm eq 'prefork') };
+
+ {
+ local $ENV{PERL_SIGNALS} = "unsafe";
+
+ eval {
+ local $SIG{ALRM} = sub { die "alarm" };
+ alarm 2;
+ run_for_5_sec();
+ alarm 0;
+ };
+ ok t_cmp $@, qr/alarm/, "SIGALRM / unsafe %SIG";
+ }
+
+ {
+ eval {
+ POSIX::sigaction(SIGALRM,
+ POSIX::SigAction->new(sub { die "alarm" }))
+ or die "Error setting SIGALRM handler: $!\n";
+ alarm 2;
+ run_for_5_sec();
+ alarm 0;
+ };
+ ok t_cmp $@, qr/alarm/, "SIGALRM / POSIX";
+ }
+
+ return Apache::OK;
+}
+
+sub run_for_5_sec {
+ for (1..20) { # ~5 sec
+ my $x = 3**20;
+ select undef, undef, undef, 0.25;
+ }
+}
+
+1;
+
+__END__