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) if $ENV{PERL_CORE_MINITEST} || !$Config{d_sigprocmask};
45 my $new = POSIX::SigSet->new(&POSIX::SIGUSR1);
46 POSIX::sigprocmask(&POSIX::SIG_BLOCK, $new);
49 $SIG{USR1} = sub { $gotit++ };
51 is $gotit, 0, 'Haven\'t received third signal yet';
53 my $old = POSIX::SigSet->new();
54 POSIX::sigsuspend($old);
55 is $gotit, 1, 'Received third signal';
59 local $SIG{USR1} = sub { die "FAIL\n" };
60 POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $old);
61 ok $old->ismember(&POSIX::SIGUSR1), 'SIGUSR1 is blocked';
62 eval { POSIX::sigsuspend(POSIX::SigSet->new) };
63 is $@, "FAIL\n", 'Exception is thrown, so received fourth signal';
64 POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $old);
65 ok $old->ismember(&POSIX::SIGUSR1), 'SIGUSR1 is still blocked';
69 is $gotit, 1, 'Haven\'t received fifth signal yet';
70 POSIX::sigprocmask(&POSIX::SIG_UNBLOCK, $new, $old);
71 ok $old->ismember(&POSIX::SIGUSR1), 'SIGUSR1 was still blocked';
72 is $gotit, 2, 'Received fifth signal';
74 # test unsafe signal handlers in combination with exceptions
75 my $action = POSIX::SigAction->new(sub { $gotit--, die }, POSIX::SigSet->new, 0);
76 POSIX::sigaction(&POSIX::SIGALRM, $action);
79 my $set = POSIX::SigSet->new;
80 POSIX::sigprocmask(&POSIX::SIG_BLOCK, undef, $set);
81 is $set->ismember(&POSIX::SIGALRM), 0, "SIGALRM is not blocked on attempt $_";
82 POSIX::sigsuspend($set);
84 is $gotit, 0, 'Received both signals';