diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/pkg/runtime/signal_freebsd_386.c | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/pkg/runtime/signal_freebsd_386.c')
-rw-r--r-- | src/pkg/runtime/signal_freebsd_386.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/pkg/runtime/signal_freebsd_386.c b/src/pkg/runtime/signal_freebsd_386.c index 80da95d98..254e5e277 100644 --- a/src/pkg/runtime/signal_freebsd_386.c +++ b/src/pkg/runtime/signal_freebsd_386.c @@ -15,7 +15,7 @@ typedef struct sigaction { void (*__sa_sigaction)(int32, Siginfo*, void *); } __sigaction_u; /* signal handler */ int32 sa_flags; /* see signal options below */ - int64 sa_mask; /* signal mask to apply */ + Sigset sa_mask; /* signal mask to apply */ } Sigaction; void @@ -54,7 +54,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; // Make it look like a call to the signal func. // Have to pass arguments out of band since @@ -97,6 +97,10 @@ Throw: runtime·printf("%s\n", runtime·sigtab[sig].name); runtime·printf("PC=%X\n", r->mc_eip); + 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()){ @@ -116,6 +120,8 @@ runtime·signalstack(byte *p, int32 n) st.ss_sp = (int8*)p; st.ss_size = n; st.ss_flags = 0; + if(p == nil) + st.ss_flags = SS_DISABLE; runtime·sigaltstack(&st, nil); } @@ -124,11 +130,23 @@ 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(sa.__sigaction_u.__sa_sigaction == SIG_IGN) + return; + } + runtime·memclr((byte*)&sa, sizeof sa); sa.sa_flags = SA_SIGINFO|SA_ONSTACK; if(restart) sa.sa_flags |= SA_RESTART; - sa.sa_mask = ~0ULL; + sa.sa_mask.__bits[0] = ~(uint32)0; + sa.sa_mask.__bits[1] = ~(uint32)0; + sa.sa_mask.__bits[2] = ~(uint32)0; + sa.sa_mask.__bits[3] = ~(uint32)0; if (fn == runtime·sighandler) fn = (void*)runtime·sigtramp; sa.__sigaction_u.__sa_sigaction = (void*)fn; |