5 unshift @INC, '../lib';
9 # Don't do anything if POSIX is missing, or sigaction missing.
12 if($@ || $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'dos' ||
13 $^O eq 'MacOS' || ($^O eq 'VMS' && !$Config{'d_sigaction'})) {
20 use vars qw/$bad7 $ok10 $bad18 $ok/;
38 my $newaction=POSIX::SigAction->new('::foo', new POSIX::SigSet(SIGUSR1), 0);
39 my $oldaction=POSIX::SigAction->new('::bar', new POSIX::SigSet(), 0);
43 local($SIG{__WARN__})=sub { $bad=1; };
44 sigaction(SIGHUP, $newaction, $oldaction);
45 if($bad) { print "not ok 1\n" } else { print "ok 1\n"}
48 if($oldaction->{HANDLER} eq 'DEFAULT' ||
49 $oldaction->{HANDLER} eq 'IGNORE')
50 { print "ok 2\n" } else { print "not ok 2 # ", $oldaction->{HANDLER}, "\n"}
51 print $SIG{HUP} eq '::foo' ? "ok 3\n" : "not ok 3\n";
53 sigaction(SIGHUP, $newaction, $oldaction);
54 if($oldaction->{HANDLER} eq '::foo')
55 { print "ok 4\n" } else { print "not ok 4\n"}
56 if($oldaction->{MASK}->ismember(SIGUSR1))
57 { print "ok 5\n" } else { print "not ok 5\n"}
58 if($oldaction->{FLAGS}) {
59 if ($^O eq 'linux' || $^O eq 'unicos') {
60 print "ok 6 # Skip: sigaction() thinks different in $^O\n";
68 $newaction=POSIX::SigAction->new('IGNORE');
69 sigaction(SIGHUP, $newaction);
71 print $bad7 ? "not ok 7\n" : "ok 7\n";
73 print $SIG{HUP} eq 'IGNORE' ? "ok 8\n" : "not ok 8\n";
74 sigaction(SIGHUP, POSIX::SigAction->new('DEFAULT'));
75 print $SIG{HUP} eq 'DEFAULT' ? "ok 9\n" : "not ok 9\n";
77 $newaction=POSIX::SigAction->new(sub { $ok10=1; });
78 sigaction(SIGHUP, $newaction);
83 print $ok10 ? "ok 10\n" : "not ok 10\n";
85 print ref($SIG{HUP}) eq 'CODE' ? "ok 11\n" : "not ok 11\n";
87 sigaction(SIGHUP, POSIX::SigAction->new('::foo'));
88 # Make sure the signal mask gets restored after sigaction croak()s.
90 my $act=POSIX::SigAction->new('::foo');
91 delete $act->{HANDLER};
92 sigaction(SIGINT, $act);
95 print $ok ? "ok 12\n" : "not ok 12\n";
98 # Make sure the signal mask gets restored after sigaction returns early.
99 my $x=defined sigaction(SIGKILL, $newaction, $oldaction);
101 print !$x && $ok ? "ok 13\n" : "not ok 13\n";
104 sigaction(SIGHUP, $newaction, $oldaction);
105 print ref($oldaction->{HANDLER}) eq 'CODE' ? "ok 14\n" : "not ok 14\n";
108 sigaction(SIGHUP, undef, $oldaction);
110 print $@ ? "not ok 15\n" : "ok 15\n";
113 sigaction(SIGHUP, 0, $oldaction);
115 print $@ ? "not ok 16\n" : "ok 16\n";
118 sigaction(SIGHUP, bless({},'Class'), $oldaction);
120 print $@ ? "ok 17\n" : "not ok 17\n";
123 print "ok 18 # Skip: SIGCONT not trappable in $^O\n";
125 $newaction=POSIX::SigAction->new(sub { $ok10=1; });
126 if (eval { SIGCONT; 1 }) {
127 sigaction(SIGCONT, POSIX::SigAction->new('DEFAULT'));
133 print $bad18 ? "not ok 18\n" : "ok 18\n";