This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Rename a variable
[perl5.git] / t / op / sigdispatch.t
index 332507f..242fb8e 100644 (file)
@@ -3,15 +3,17 @@
 # We assume that TestInit has been used.
 
 BEGIN {
+      chdir 't' if -d 't';
       require './test.pl';
 }
 
 use strict;
 use Config;
 
-plan tests => 26;
+plan tests => 29;
+$| = 1;
 
-watchdog(15);
+watchdog(25);
 
 $SIG{ALRM} = sub {
     die "Alarm!\n";
@@ -41,8 +43,10 @@ is($@, "Alarm!\n", 'after the second loop');
 SKIP: {
     skip('We can\'t test blocking without sigprocmask', 17)
        if is_miniperl() || !$Config{d_sigprocmask};
-    skip('This doesn\'t work on $^O threaded builds RT#88814', 17)
-        if $^O =~ /openbsd|cygwin/ && $Config{useithreads};
+    skip("This doesn\'t work on $^O threaded builds RT#88814", 17)
+        if ($^O =~ /cygwin/ && $Config{useithreads});
+    skip("This doesn\'t work on $^O version $Config{osvers} RT#88814", 17)
+        if ($^O eq "openbsd" && $Config{osvers} < 5.2);
 
     require POSIX;
     my $pending = POSIX::SigSet->new();
@@ -89,16 +93,27 @@ TODO:
     is $gotit, 2, 'Received fifth signal';
 
     # test unsafe signal handlers in combination with exceptions
-    my $action = POSIX::SigAction->new(sub { $gotit--, die }, POSIX::SigSet->new, 0);
-    POSIX::sigaction(&POSIX::SIGALRM, $action);
-    eval {
-        alarm 1;
-        my $set = POSIX::SigSet->new;
-        POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $set);
-        is $set->ismember(&POSIX::SIGALRM), 0, "SIGALRM is not blocked on attempt $_";
-        POSIX::sigsuspend($set);
-    } for 1..2;
-    is $gotit, 0, 'Received both signals';
+
+    SKIP: {
+       # #89718: on old linux kernels, this test hangs. No-ones thought
+       # of a reliable way to probe for this, so for now, just skip the
+       # tests on production releases
+       skip("some OSes hang here", 3) if (int($]*1000) & 1) == 0;
+    
+  SKIP: {
+       skip("Issues on Android", 3) if $^O =~ /android/;
+       my $action = POSIX::SigAction->new(sub { $gotit--, die }, POSIX::SigSet->new, 0);
+       POSIX::sigaction(&POSIX::SIGALRM, $action);
+       eval {
+           alarm 1;
+           my $set = POSIX::SigSet->new;
+           POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $set);
+           is $set->ismember(&POSIX::SIGALRM), 0, "SIGALRM is not blocked on attempt $_";
+           POSIX::sigsuspend($set);
+       } for 1..2;
+       is $gotit, 0, 'Received both signals';
+    }
+}
 }
 
 SKIP: {
@@ -139,3 +154,16 @@ like $@, qr/No such hook: __DIE__\\0whoops at/;
     $SIG{"KILL\0"} = sub { 1 };
     like $w, qr/No such signal: SIGKILL\\0 at/, 'Arbitrary signal lookup through %SIG is clean';
 }
+
+# [perl #45173]
+{
+    my $int_called;
+    local $SIG{INT} = sub { $int_called = 1; };
+    $@ = "died";
+    is($@, "died");
+    kill 'INT', $$;
+    # this is needed to ensure signal delivery on MSWin32
+    sleep(1);
+    is($int_called, 1);
+    is($@, "died");
+}