summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/signal_darwin_amd64.c
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-03-04 21:27:36 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-03-04 21:27:36 +0100
commit04b08da9af0c450d645ab7389d1467308cfc2db8 (patch)
treedb247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/pkg/runtime/signal_darwin_amd64.c
parent917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff)
downloadgolang-upstream/1.1_hg20130304.tar.gz
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/pkg/runtime/signal_darwin_amd64.c')
-rw-r--r--src/pkg/runtime/signal_darwin_amd64.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/pkg/runtime/signal_darwin_amd64.c b/src/pkg/runtime/signal_darwin_amd64.c
index d9c5f48e7..4b7256bf4 100644
--- a/src/pkg/runtime/signal_darwin_amd64.c
+++ b/src/pkg/runtime/signal_darwin_amd64.c
@@ -55,7 +55,7 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp)
t = &runtime·sigtab[sig];
if(info->si_code != SI_USER && (t->flags & SigPanic)) {
- if(gp == nil)
+ if(gp == nil || gp == m->g0)
goto Throw;
// Work around Leopard bug that doesn't set FPE_INTDIV.
// Look at instruction to see if it is a divide.
@@ -111,7 +111,11 @@ Throw:
runtime·printf("%s\n", runtime·sigtab[sig].name);
}
- runtime·printf("pc: %X\n", r->rip);
+ runtime·printf("PC=%X\n", r->rip);
+ if(m->lockedg != nil && m->ncgo > 0 && gp == m->g0) {
+ runtime·printf("signal arrived during cgo execution\n");
+ gp = m->lockedg;
+ }
runtime·printf("\n");
if(runtime·gotraceback()){
@@ -131,6 +135,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
+ if(p == nil)
+ st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
@@ -139,6 +145,15 @@ runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart)
{
Sigaction sa;
+ // If SIGHUP handler is SIG_IGN, assume running
+ // under nohup and do not set explicit handler.
+ if(i == SIGHUP) {
+ runtime·memclr((byte*)&sa, sizeof sa);
+ runtime·sigaction(i, nil, &sa);
+ if(*(void**)sa.__sigaction_u == SIG_IGN)
+ return;
+ }
+
runtime·memclr((byte*)&sa, sizeof sa);
sa.sa_flags = SA_SIGINFO|SA_ONSTACK;
if(restart)