5 unshift @INC, '../lib';
9 # Don't do anything if POSIX is missing, or sigaction missing.
11 if($@ || $^O eq 'MSWin32' || $^O eq 'NetWare') {
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 $oldaction->{HANDLER} eq 'IGNORE')
48 { print "ok 2\n" } else { print "not ok 2 # ", $oldaction->{HANDLER}, "\n"}
49 print $SIG{HUP} eq '::foo' ? "ok 3\n" : "not ok 3\n";
51 sigaction(SIGHUP, $newaction, $oldaction);
52 if($oldaction->{HANDLER} eq '::foo')
53 { print "ok 4\n" } else { print "not ok 4\n"}
54 if($oldaction->{MASK}->ismember(SIGUSR1))
55 { print "ok 5\n" } else { print "not ok 5\n"}
56 if($oldaction->{FLAGS}) {
58 print "ok 6 # Skip: sigaction() broken in $^O\n";
66 $newaction=POSIX::SigAction->new('IGNORE');
67 sigaction(SIGHUP, $newaction);
69 print $bad7 ? "not ok 7\n" : "ok 7\n";
71 print $SIG{HUP} eq 'IGNORE' ? "ok 8\n" : "not ok 8\n";
72 sigaction(SIGHUP, POSIX::SigAction->new('DEFAULT'));
73 print $SIG{HUP} eq 'DEFAULT' ? "ok 9\n" : "not ok 9\n";
75 $newaction=POSIX::SigAction->new(sub { $ok10=1; });
76 sigaction(SIGHUP, $newaction);
81 print $ok10 ? "ok 10\n" : "not ok 10\n";
83 print ref($SIG{HUP}) eq 'CODE' ? "ok 11\n" : "not ok 11\n";
85 sigaction(SIGHUP, POSIX::SigAction->new('::foo'));
86 # Make sure the signal mask gets restored after sigaction croak()s.
88 my $act=POSIX::SigAction->new('::foo');
89 delete $act->{HANDLER};
90 sigaction(SIGINT, $act);
93 print $ok ? "ok 12\n" : "not ok 12\n";
96 # Make sure the signal mask gets restored after sigaction returns early.
97 my $x=defined sigaction(SIGKILL, $newaction, $oldaction);
99 print !$x && $ok ? "ok 13\n" : "not ok 13\n";
102 sigaction(SIGHUP, $newaction, $oldaction);
103 print ref($oldaction->{HANDLER}) eq 'CODE' ? "ok 14\n" : "not ok 14\n";
106 sigaction(SIGHUP, undef, $oldaction);
108 print $@ ? "not ok 15\n" : "ok 15\n";
111 sigaction(SIGHUP, 0, $oldaction);
113 print $@ ? "not ok 16\n" : "ok 16\n";
116 sigaction(SIGHUP, bless({},'Class'), $oldaction);
118 print $@ ? "ok 17\n" : "not ok 17\n";
120 $newaction=POSIX::SigAction->new(sub { $ok10=1; });
121 sigaction(SIGCONT, POSIX::SigAction->new('DEFAULT'));
126 print $bad18 ? "not ok 18\n" : "ok 18\n";