3 # We assume that TestInit has been used.
20 pass('before the first loop');
28 is($@, "Alarm!\n", 'after the first loop');
30 pass('before the second loop');
39 is($@, "Alarm!\n", 'after the second loop');
42 skip('We can\'t test blocking without sigprocmask', 11)
43 if is_miniperl() || !$Config{d_sigprocmask};
44 skip('This doesn\'t work on OpenBSD threaded builds RT#88814', 11)
45 if $^O eq 'openbsd' && $Config{useithreads};
48 my $new = POSIX::SigSet->new(&POSIX::SIGUSR1);
49 POSIX::sigprocmask(&POSIX::SIG_BLOCK, $new);
52 $SIG{USR1} = sub { $gotit++ };
54 is $gotit, 0, 'Haven\'t received third signal yet';
56 my $old = POSIX::SigSet->new();
57 POSIX::sigsuspend($old);
58 is $gotit, 1, 'Received third signal';
62 local $SIG{USR1} = sub { die "FAIL\n" };
63 POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $old);
64 ok $old->ismember(&POSIX::SIGUSR1), 'SIGUSR1 is blocked';
65 eval { POSIX::sigsuspend(POSIX::SigSet->new) };
66 is $@, "FAIL\n", 'Exception is thrown, so received fourth signal';
67 POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $old);
70 local $::TODO = "Needs investigation" if $^O eq 'VMS';
71 ok $old->ismember(&POSIX::SIGUSR1), 'SIGUSR1 is still blocked';
75 POSIX::sigprocmask(&POSIX::SIG_BLOCK, $new);
77 is $gotit, 1, 'Haven\'t received fifth signal yet';
78 POSIX::sigprocmask(&POSIX::SIG_UNBLOCK, $new, $old);
79 ok $old->ismember(&POSIX::SIGUSR1), 'SIGUSR1 was still blocked';
80 is $gotit, 2, 'Received fifth signal';
82 # test unsafe signal handlers in combination with exceptions
83 my $action = POSIX::SigAction->new(sub { $gotit--, die }, POSIX::SigSet->new, 0);
84 POSIX::sigaction(&POSIX::SIGALRM, $action);
87 my $set = POSIX::SigSet->new;
88 POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $set);
89 is $set->ismember(&POSIX::SIGALRM), 0, "SIGALRM is not blocked on attempt $_";
90 POSIX::sigsuspend($set);
92 is $gotit, 0, 'Received both signals';
96 skip("alarm cannot interrupt blocking system calls on $^O", 2)
97 if ($^O eq 'MSWin32' || $^O eq 'VMS');
99 # make sure the signal handler's called in an eval block *before*
102 $SIG{'ALRM'} = sub { die "HANDLER CALLED\n" };
106 select(undef,undef,undef,10);
109 is($@, "HANDLER CALLED\n", 'block eval');
113 select(undef,undef,undef,10);
116 is($@, "HANDLER CALLED\n", 'string eval');