aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/thread_linux.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-02-15 11:18:55 -0500
committerRuss Cox <rsc@golang.org>2013-02-15 11:18:55 -0500
commitf3407f445d51dac3b9415cb5025ac98ccbbc80eb (patch)
tree98c136267db30a124781f60f0d4a7a3014fc84a9 /src/pkg/runtime/thread_linux.c
parent5b20a18f3b985cdf116a0ea6dd589d26056b16ad (diff)
downloadgo-f3407f445d51dac3b9415cb5025ac98ccbbc80eb.tar.xz
runtime: fix running under nohup
There are two ways nohup(1) might be implemented: it might mask away the signal, or it might set the handler to SIG_IGN, both of which are inherited across fork+exec. So two fixes: * Make sure to preserve the inherited signal mask at minit instead of clearing it. * If the SIGHUP handler is SIG_IGN, leave it that way. Fixes #4491. R=golang-dev, mikioh.mikioh, iant CC=golang-dev https://golang.org/cl/7308102
Diffstat (limited to 'src/pkg/runtime/thread_linux.c')
-rw-r--r--src/pkg/runtime/thread_linux.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pkg/runtime/thread_linux.c b/src/pkg/runtime/thread_linux.c
index 778b9078b9..604b98e57f 100644
--- a/src/pkg/runtime/thread_linux.c
+++ b/src/pkg/runtime/thread_linux.c
@@ -14,7 +14,6 @@ int32 runtime·close(int32);
int32 runtime·read(int32, void*, int32);
static Sigset sigset_all = { ~(uint32)0, ~(uint32)0 };
-static Sigset sigset_none;
// Linux futex.
//
@@ -149,6 +148,8 @@ runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
// Disable signals during clone, so that the new thread starts
// with signals disabled. It will enable them in minit.
runtime·rtsigprocmask(SIG_SETMASK, &sigset_all, &oset, sizeof oset);
+ mp->sigset = runtime·mal(sizeof(Sigset));
+ *(Sigset*)mp->sigset = oset;
ret = runtime·clone(flags, stk, mp, gp, fn);
runtime·rtsigprocmask(SIG_SETMASK, &oset, nil, sizeof oset);
@@ -177,7 +178,8 @@ runtime·minit(void)
// Initialize signal handling.
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
- runtime·rtsigprocmask(SIG_SETMASK, &sigset_none, nil, sizeof sigset_none);
+ if(m->sigset != nil)
+ runtime·rtsigprocmask(SIG_SETMASK, m->sigset, nil, sizeof *m->sigset);
}
void