Synopsis:
- sigaction(sig, action, oldaction = 0)
+ sigaction(signal, action, oldaction = 0)
-Returns C<undef> on failure.
+Returns C<undef> on failure. The C<signal> must be a number (like
+SIGHUP), not a string (like "SIGHUP"), though Perl does try hard
+to understand you.
=item siglongjmp
sigset_t osset;
POSIX__SigSet sigset;
SV** svp;
- SV** sigsvp = hv_fetch(GvHVn(siggv),
- PL_sig_name[sig],
- strlen(PL_sig_name[sig]),
- TRUE);
+ SV** sigsvp;
+ if (sig == 0 && SvPOK(ST(0))) {
+ char *s = SvPVX(ST(0));
+ int i = whichsig(s);
+
+ if (i < 0 && memEQ(s, "SIG", 3))
+ i = whichsig(s + 3);
+ if (i < 0) {
+ if (ckWARN(WARN_SIGNAL))
+ Perl_warner(aTHX_ packWARN(WARN_SIGNAL),
+ "No such signal: SIG%s", s);
+ XSRETURN_UNDEF;
+ }
+ else
+ sig = i;
+ }
+ sigsvp = hv_fetch(GvHVn(siggv),
+ PL_sig_name[sig],
+ strlen(PL_sig_name[sig]),
+ TRUE);
/* Check optaction and set action */
if(SvTRUE(optaction)) {
* in between. We use sigprocmask() to make it so.
*/
sigfillset(&sset);
+#if 0
RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
if(RETVAL == -1)
XSRETURN_UNDEF;
+#endif
ENTER;
/* Restore signal mask no matter how we exit this block. */
osset_sv = newSVpv((char *)(&osset), sizeof(sigset_t));
$^W=1;
-print "1..18\n";
+print "1..21\n";
sub IGNORE {
$bad7=1;
print $bad18 ? "not ok 18\n" : "ok 18\n";
}
+{
+ local $SIG{__WARN__} = sub { }; # Just suffer silently.
+
+ my $hup20;
+ my $hup21;
+
+ sub hup20 { $hup20++ }
+ sub hup21 { $hup21++ }
+
+ sigaction("FOOBAR", $newaction);
+ print "ok 19\n"; # no coredump, still alive
+
+ $newaction = POSIX::SigAction->new("hup20");
+ sigaction("SIGHUP", $newaction);
+ kill "HUP", $$;
+ print $hup20 == 1 ? "ok 20\n" : "not ok 20\n";
+
+ $newaction = POSIX::SigAction->new("hup21");
+ sigaction("HUP", $newaction);
+ kill "HUP", $$;
+ print $hup21 == 1 ? "ok 21\n" : "not ok 21\n";
+}