Index: src/pkg/runtime/signal_freebsd_386.c |
=================================================================== |
--- a/src/pkg/runtime/signal_freebsd_386.c |
+++ b/src/pkg/runtime/signal_freebsd_386.c |
@@ -50,6 +50,7 @@ |
Ucontext *uc; |
Mcontext *r; |
uintptr *sp; |
+ SigTab *t; |
uc = context; |
r = &uc->uc_mcontext; |
@@ -59,7 +60,10 @@ |
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 |
@@ -84,12 +88,15 @@ |
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(t->flags & SigKill) |
+ runtime·exit(2); |
+ if(!(t->flags & SigThrow)) |
+ return; |
+Throw: |
if(runtime·panicking) // traceback already printed |
runtime·exit(2); |
runtime·panicking = 1; |
@@ -111,13 +118,6 @@ |
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) |
{ |
@@ -129,8 +129,8 @@ |
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; |
@@ -144,50 +144,3 @@ |
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(); |
-} |