when 'local $SIG{ALRM} = sub {...}' goes out of scope, magic_setsig() sets
the SIGALRM handler to SIG_DFL, rather than the original handler.  this
causes quite a bit of trouble running inside of apache, since 'local
$SIG{ALRM}' unhooks the apache SIGALRM handler for the life of that
proccess.
the original handler is already fetched by magic_getsig(), this patch
saves that pointer so it can be restored in magic_setsig().

--- mg.c~       Sat Mar 18 19:41:03 2000
+++ mg.c        Tue Mar 28 22:37:07 2000
@@ -967,7 +967,7 @@
            if(sigstate == SIG_IGN)
                sv_setpv(sv,"IGNORE");
            else
-               sv_setsv(sv,&PL_sv_undef);
+               sv_setiv(sv,(IV)sigstate);
            PL_psig_ptr[i] = SvREFCNT_inc(sv);
            SvTEMP_off(sv);
        }
@@ -1002,6 +1002,7 @@
     I32 i;
     SV** svp;
     STRLEN len;
+    Sighandler_t sigstate = 0;
 
     s = MgPV(mg,len);
     if (*s == '_') {
@@ -1038,16 +1039,21 @@
            *svp = SvREFCNT_inc(sv);
        return 0;
     }
-    s = SvPV_force(sv,len);
+    if (SvIOK(sv)) {
+       sigstate = (Sighandler_t)SvIVX(sv);
+    }
+    else {
+       s = SvPV_force(sv,len);
+    }
     if (strEQ(s,"IGNORE")) {
        if (i)
            (void)rsignal(i, SIG_IGN);
        else
            *svp = 0;
     }
-    else if (strEQ(s,"DEFAULT") || !*s) {
+    else if (strEQ(s,"DEFAULT") || !*s || sigstate) {
        if (i)
-           (void)rsignal(i, SIG_DFL);
+           (void)rsignal(i, sigstate ? sigstate : SIG_DFL);
        else
            *svp = 0;
     }

Reply via email to