diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-01-17 22:41:10 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-01-17 22:41:10 +0000 |
commit | 0a8e0eff0300ee74cef43b18ff11d05a6376450e (patch) | |
tree | b7b923b1cedae412a37ad43239ef3327d1ca1c52 /mg.c | |
parent | 9b5a166df944a05919fc72a0c76a3ff67c30dc35 (diff) | |
download | perl-0a8e0eff0300ee74cef43b18ff11d05a6376450e.tar.gz |
"Safe" signals - trial implementation.
gv.c tweaked to zero PL_sig_pend array
perlio.c tweaked to PERL_ASYNC_CHECK() on EINTR
util.c tweaked to not set SA_RESTART to give perlio.c a chance.
Odd thing is that it "works" with PERLIO=stdio as well (linux).
p4raw-id: //depot/perlio@8467
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 49 |
1 files changed, 37 insertions, 12 deletions
@@ -996,6 +996,40 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC *mg) return 0; } +void +Perl_raise_signal(pTHX_ int sig) +{ + /* Set a flag to say this signal is pending */ + PL_psig_pend[sig]++; + /* And one to say _a_ signal is pending */ + PL_sig_pending = 1; +} + +Signal_t +Perl_csighandler(int sig) +{ +#ifdef PERL_OLD_SIGNALS + /* Call the perl level handler now with risk we may be in malloc() etc. */ + (*PL_sighandlerp)(sig); +#else + dTHX; + Perl_raise_signal(aTHX_ sig); +#endif +} + +void +Perl_despatch_signals(pTHX) +{ + int sig; + PL_sig_pending = 0; + for (sig = 1; sig < SIG_SIZE; sig++) { + if (PL_psig_pend[sig]) { + PL_psig_pend[sig] = 0; + (*PL_sighandlerp)(sig); + } + } +} + int Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg) { @@ -1034,7 +1068,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg) } if (SvTYPE(sv) == SVt_PVGV || SvROK(sv)) { if (i) - (void)rsignal(i, PL_sighandlerp); + (void)rsignal(i, &Perl_csighandler); else *svp = SvREFCNT_inc(sv); return 0; @@ -1061,7 +1095,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg) if (!strchr(s,':') && !strchr(s,'\'')) sv_insert(sv, 0, 0, "main::", 6); if (i) - (void)rsignal(i, PL_sighandlerp); + (void)rsignal(i, &Perl_csighandler); else *svp = SvREFCNT_inc(sv); } @@ -2145,15 +2179,6 @@ Perl_whichsig(pTHX_ char *sig) return 0; } -void -Perl_despatch_signals(pTHX) -{ -#ifndef PERL_OLD_SIGNALS - /* This is just a dummy for now */ -#endif - PL_sig_pending = 0; -} - static SV* sig_sv; Signal_t @@ -2251,7 +2276,7 @@ Perl_sighandler(int sig) #else /* Not clear if this will work */ (void)rsignal(sig, SIG_IGN); - (void)rsignal(sig, PL_sighandlerp); + (void)rsignal(sig, &Perl_csighandler); #endif Perl_die(aTHX_ Nullch); } |