summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-31 17:30:28 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-31 17:30:28 +0000
commit598519186ce2f4c4b2abe7bb8e1639ec1258310b (patch)
tree174429a76d5ac9c87abb2dd2e798fa9d5049fe51 /libgo
parent29416343179a978767229f20f32f5c7835c41c99 (diff)
downloadgcc-598519186ce2f4c4b2abe7bb8e1639ec1258310b.tar.gz
runtime: Block signals when creating a new thread.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195619 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/runtime/proc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index 6d9007614b9..b59f4acf0dc 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
#include <limits.h>
+#include <signal.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
@@ -1217,6 +1218,9 @@ runtime_newm(void)
pthread_attr_t attr;
pthread_t tid;
size_t stacksize;
+ sigset_t clear;
+ sigset_t old;
+ int ret;
#if 0
static const Type *mtype; // The Go type M
@@ -1249,7 +1253,15 @@ runtime_newm(void)
if(pthread_attr_setstacksize(&attr, stacksize) != 0)
runtime_throw("pthread_attr_setstacksize");
- if(pthread_create(&tid, &attr, runtime_mstart, mp) != 0)
+ // Block signals during pthread_create so that the new thread
+ // starts with signals disabled. It will enable them in minit.
+ sigfillset(&clear);
+ sigemptyset(&old);
+ sigprocmask(SIG_BLOCK, &clear, &old);
+ ret = pthread_create(&tid, &attr, runtime_mstart, mp);
+ sigprocmask(SIG_SETMASK, &old, nil);
+
+ if (ret != 0)
runtime_throw("pthread_create");
return mp;