8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # Don't do anything if POSIX is missing, or sigaction missing.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if($@ || $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'dos' ||
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $^O eq 'MacOS' || ($^O eq 'VMS' && !$Config{'d_sigaction'})) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprint "1..25\n";
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottmy $newaction=POSIX::SigAction->new('::foo', new POSIX::SigSet(SIGUSR1), 0);
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshottmy $oldaction=POSIX::SigAction->new('::bar', new POSIX::SigSet(), 0);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if($bad) { print "not ok 1\n" } else { print "ok 1\n"}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster { print "ok 2\n" } else { print "not ok 2 # ", $oldaction->{HANDLER}, "\n"}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprint $SIG{HUP} eq '::foo' ? "ok 3\n" : "not ok 3\n";
72450cb9c2ca854c6d3479832c2738196c1d3282Robert Wapshott { print "ok 5\n" } else { print "not ok 5\n"}
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott print "ok 6 # Skip: sigaction() thinks different in $^O\n";
01a939641aeb0a095851921879620c3fab295cb2Robert Wapshottprint $SIG{HUP} eq 'IGNORE' ? "ok 8\n" : "not ok 8\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostersigaction(SIGHUP, POSIX::SigAction->new('DEFAULT'));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprint $SIG{HUP} eq 'DEFAULT' ? "ok 9\n" : "not ok 9\n";
cc7c18212481f5e9ee508afe2ffcaecb6b9330f5Craig McDonnell$newaction=POSIX::SigAction->new(sub { $ok10=1; });
0c893a059f84246bf91e2f0fbf63e4c92f8e5165Tony Bamfordprint ref($SIG{HUP}) eq 'CODE' ? "ok 11\n" : "not ok 11\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostersigaction(SIGHUP, POSIX::SigAction->new('::foo'));
0c893a059f84246bf91e2f0fbf63e4c92f8e5165Tony Bamford# Make sure the signal mask gets restored after sigaction croak()s.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# Make sure the signal mask gets restored after sigaction returns early.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostermy $x=defined sigaction(SIGKILL, $newaction, $oldaction);
0c893a059f84246bf91e2f0fbf63e4c92f8e5165Tony Bamfordprint ref($oldaction->{HANDLER}) eq 'CODE' ? "ok 14\n" : "not ok 14\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sigaction(SIGHUP, bless({},'Class'), $oldaction);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster print "ok 18 # Skip: SIGCONT not trappable in $^O\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $newaction=POSIX::SigAction->new(sub { $ok10=1; });
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sigaction(SIGCONT, POSIX::SigAction->new('DEFAULT'));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster local $SIG{__WARN__} = sub { }; # Just suffer silently.
fd21d481e26774c37a197c7cc8ab56096a21e7aaPhill Cunnington# "safe" attribute.
fd21d481e26774c37a197c7cc8ab56096a21e7aaPhill Cunnington# for this one, use the accessor instead of the attribute
fd21d481e26774c37a197c7cc8ab56096a21e7aaPhill Cunnington# standard signal handling via %SIG is safe
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprint $oldaction->safe ? "ok 22\n" : "not ok 22\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# SigAction handling is not safe ...
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostersigaction(SIGHUP, POSIX::SigAction->new(\&foo));
cc7c18212481f5e9ee508afe2ffcaecb6b9330f5Craig McDonnellprint $oldaction->safe ? "not ok 23\n" : "ok 23\n";
cc7c18212481f5e9ee508afe2ffcaecb6b9330f5Craig McDonnell# ... unless we say so!
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterprint $oldaction->safe ? "ok 24\n" : "not ok 24\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# And safe signal delivery must work