5 unshift @INC, '../lib';
9 # Don't do anything if POSIX is missing, or sigaction missing.
11 if($@ || $^O eq 'MSWin32') {
18 use vars qw/$bad7 $ok10 $bad18 $ok/;
36 my $newaction=POSIX::SigAction->new('::foo', new POSIX::SigSet(SIGUSR1), 0);
37 my $oldaction=POSIX::SigAction->new('::bar', new POSIX::SigSet(), 0);
41 local($SIG{__WARN__})=sub { $bad=1; };
42 sigaction(SIGHUP, $newaction, $oldaction);
43 if($bad) { print "not ok 1\n" } else { print "ok 1\n"}
46 if($oldaction->{HANDLER} eq 'DEFAULT')
47 { print "ok 2\n" } else { print "not ok 2\n"}
48 print $SIG{HUP} eq '::foo' ? "ok 3\n" : "not ok 3\n";
50 sigaction(SIGHUP, $newaction, $oldaction);
51 if($oldaction->{HANDLER} eq '::foo')
52 { print "ok 4\n" } else { print "not ok 4\n"}
53 if($oldaction->{MASK}->ismember(SIGUSR1))
54 { print "ok 5\n" } else { print "not ok 5\n"}
55 if($oldaction->{FLAGS}) {
57 print "ok 6 # Skip: sigaction() broken in $^O\n";
65 $newaction=POSIX::SigAction->new('IGNORE');
66 sigaction(SIGHUP, $newaction);
68 print $bad7 ? "not ok 7\n" : "ok 7\n";
70 print $SIG{HUP} eq 'IGNORE' ? "ok 8\n" : "not ok 8\n";
71 sigaction(SIGHUP, POSIX::SigAction->new('DEFAULT'));
72 print $SIG{HUP} eq 'DEFAULT' ? "ok 9\n" : "not ok 9\n";
74 $newaction=POSIX::SigAction->new(sub { $ok10=1; });
75 sigaction(SIGHUP, $newaction);
80 print $ok10 ? "ok 10\n" : "not ok 10\n";
82 print ref($SIG{HUP}) eq 'CODE' ? "ok 11\n" : "not ok 11\n";
84 sigaction(SIGHUP, POSIX::SigAction->new('::foo'));
85 # Make sure the signal mask gets restored after sigaction croak()s.
87 my $act=POSIX::SigAction->new('::foo');
88 delete $act->{HANDLER};
89 sigaction(SIGINT, $act);
92 print $ok ? "ok 12\n" : "not ok 12\n";
95 # Make sure the signal mask gets restored after sigaction returns early.
96 my $x=defined sigaction(SIGKILL, $newaction, $oldaction);
98 print !$x && $ok ? "ok 13\n" : "not ok 13\n";
101 sigaction(SIGHUP, $newaction, $oldaction);
102 print ref($oldaction->{HANDLER}) eq 'CODE' ? "ok 14\n" : "not ok 14\n";
105 sigaction(SIGHUP, undef, $oldaction);
107 print $@ ? "not ok 15\n" : "ok 15\n";
110 sigaction(SIGHUP, 0, $oldaction);
112 print $@ ? "not ok 16\n" : "ok 16\n";
115 sigaction(SIGHUP, bless({},'Class'), $oldaction);
117 print $@ ? "ok 17\n" : "not ok 17\n";
119 $newaction=POSIX::SigAction->new(sub { $ok10=1; });
120 sigaction(SIGCONT, POSIX::SigAction->new('DEFAULT'));
125 print $bad18 ? "not ok 18\n" : "ok 18\n";