diff options
Diffstat (limited to 'src/pkg/runtime/signal_openbsd_amd64.c')
-rw-r--r-- | src/pkg/runtime/signal_openbsd_amd64.c | 88 |
1 files changed, 15 insertions, 73 deletions
diff --git a/src/pkg/runtime/signal_openbsd_amd64.c b/src/pkg/runtime/signal_openbsd_amd64.c index 6c69fa733..8b4f624e7 100644 --- a/src/pkg/runtime/signal_openbsd_amd64.c +++ b/src/pkg/runtime/signal_openbsd_amd64.c @@ -44,19 +44,12 @@ runtime·dumpregs(Sigcontext *r) runtime·printf("gs %X\n", r->sc_gs); } -String -runtime·signame(int32 sig) -{ - if(sig < 0 || sig >= NSIG) - return runtime·emptystring; - return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name); -} - void runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp) { Sigcontext *r = context; uintptr *sp; + SigTab *t; if(sig == SIGPROF) { runtime·sigprof((uint8*)r->sc_rip, @@ -64,7 +57,10 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp) return; } - if(gp != nil && (runtime·sigtab[sig].flags & SigPanic)) { + t = &runtime·sigtab[sig]; + if(info->si_code != SI_USER && (t->flags & SigPanic)) { + if(gp == nil) + goto Throw; // Make it look like a call to the signal func. // Have to pass arguments out of band since // augmenting the stack frame would break @@ -89,16 +85,16 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp) return; } - if(runtime·sigtab[sig].flags & SigQueue) { - if(runtime·sigsend(sig) - || (runtime·sigtab[sig].flags & SigIgnore)) + if(info->si_code == SI_USER || (t->flags & SigNotify)) + if(runtime·sigsend(sig)) return; - runtime·exit(2); // SIGINT, SIGTERM, etc - } - - if(runtime·panicking) // traceback already printed + if(t->flags & SigKill) runtime·exit(2); - runtime·panicking = 1; + if(!(t->flags & SigThrow)) + return; + +Throw: + runtime·startpanic(); if(sig < 0 || sig >= NSIG) runtime·printf("Signal %d\n", sig); @@ -117,13 +113,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp) runtime·exit(2); } -// Called from kernel on signal stack, so no stack split. -#pragma textflag 7 -void -runtime·sigignore(void) -{ -} - void runtime·signalstack(byte *p, int32 n) { @@ -135,8 +124,8 @@ runtime·signalstack(byte *p, int32 n) runtime·sigaltstack(&st, nil); } -static void -sigaction(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) +void +runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) { Sigaction sa; @@ -150,50 +139,3 @@ sigaction(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) sa.__sigaction_u.__sa_sigaction = (void*)fn; runtime·sigaction(i, &sa, nil); } - -void -runtime·initsig(int32 queue) -{ - int32 i; - void *fn; - - runtime·siginit(); - - for(i = 0; i<NSIG; i++) { - if(runtime·sigtab[i].flags) { - if((runtime·sigtab[i].flags & SigQueue) != queue) - continue; - if(runtime·sigtab[i].flags & (SigCatch | SigQueue)) - fn = runtime·sighandler; - else - fn = runtime·sigignore; - sigaction(i, fn, (runtime·sigtab[i].flags & SigRestart) != 0); - } - } -} - -void -runtime·resetcpuprofiler(int32 hz) -{ - Itimerval it; - - runtime·memclr((byte*)&it, sizeof it); - if(hz == 0) { - runtime·setitimer(ITIMER_PROF, &it, nil); - sigaction(SIGPROF, SIG_IGN, true); - } else { - sigaction(SIGPROF, runtime·sighandler, true); - it.it_interval.tv_sec = 0; - it.it_interval.tv_usec = 1000000 / hz; - it.it_value = it.it_interval; - runtime·setitimer(ITIMER_PROF, &it, nil); - } - m->profilehz = hz; -} - -void -os·sigpipe(void) -{ - sigaction(SIGPIPE, SIG_DFL, false); - runtime·raisesigpipe(); -} |