perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r109528 - /perl/modperl/trunk/t/response/TestPerl/signals.pm
Date Thu, 02 Dec 2004 19:52:39 GMT
Author: stas
Date: Thu Dec  2 11:52:38 2004
New Revision: 109528

URL: http://svn.apache.org/viewcvs?view=rev&rev=109528
Log:
- signal handlers don't work anywhere but with prefork,
- POSIX::sigaction doesn't work under 5.6.x

Modified:
   perl/modperl/trunk/t/response/TestPerl/signals.pm

Modified: perl/modperl/trunk/t/response/TestPerl/signals.pm
Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestPerl/signals.pm?view=diff&rev=109528&p1=perl/modperl/trunk/t/response/TestPerl/signals.pm&r1=109527&p2=perl/modperl/trunk/t/response/TestPerl/signals.pm&r2=109528
==============================================================================
--- perl/modperl/trunk/t/response/TestPerl/signals.pm	(original)
+++ perl/modperl/trunk/t/response/TestPerl/signals.pm	Thu Dec  2 11:52:38 2004
@@ -10,18 +10,20 @@
 
 use POSIX qw(SIGALRM);
 
+#use POSIX ':signal_h';
+
 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?)
+# signal handlers don't work anywhere but with prefork, since signals
+# and threads don't mix
 
 sub handler {
     my $r = shift;
 
     plan $r, tests => 2,
-        need { "works for prefork" => ($mpm eq 'prefork') };
+        need { "works only for prefork" => ($mpm eq 'prefork') };
 
     {
         local $ENV{PERL_SIGNALS} = "unsafe";
@@ -35,16 +37,23 @@
         ok t_cmp $@, qr/alarm/, "SIGALRM / unsafe %SIG";
     }
 
-    {
+    # POSIX::sigaction doesn't work under 5.6.x
+    if ($] >= 5.008) {
+        my $mask = POSIX::SigSet->new( SIGALRM );
+        my $action = POSIX::SigAction->new(sub { die "alarm" }, $mask);
+        my $oldaction = POSIX::SigAction->new();
+        POSIX::sigaction(SIGALRM, $action, $oldaction );
         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;
         };
+        POSIX::sigaction(SIGALRM, $oldaction); # restore original
+
         ok t_cmp $@, qr/alarm/, "SIGALRM / POSIX";
+    }
+    else {
+        skip "POSIX::sigaction doesn't work under 5.6.x", 0;
     }
 
     return Apache::OK;

Mime
View raw message