diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-02-12 22:10:09 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-02-12 22:10:09 +0000 |
commit | 54c9c975f182aacae65a925b86b8770e2503b950 (patch) | |
tree | 0f1bf2665d8697cd161c1f9d5271e3db262ac73e /libgo/runtime/signal_unix.c | |
parent | 37064e3daf756e60b7725b8fee74ddb6785511ac (diff) | |
download | gcc-54c9c975f182aacae65a925b86b8770e2503b950.zip gcc-54c9c975f182aacae65a925b86b8770e2503b950.tar.gz gcc-54c9c975f182aacae65a925b86b8770e2503b950.tar.bz2 |
runtime: For c-archive/c-shared, install signal handlers synchronously.
This is a port of https://golang.org/cl/18150 to the gccgo runtime.
The previous behaviour of installing the signal handlers in a separate
thread meant that Go initialization raced with non-Go initialization if
the non-Go initialization also wanted to install signal handlers. Make
installing signal handlers synchronous so that the process-wide behavior
is predictable.
Reviewed-on: https://go-review.googlesource.com/19494
From-SVN: r233393
Diffstat (limited to 'libgo/runtime/signal_unix.c')
-rw-r--r-- | libgo/runtime/signal_unix.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libgo/runtime/signal_unix.c b/libgo/runtime/signal_unix.c index 2028933..5bee0d2 100644 --- a/libgo/runtime/signal_unix.c +++ b/libgo/runtime/signal_unix.c @@ -13,11 +13,16 @@ extern SigTab runtime_sigtab[]; void -runtime_initsig(void) +runtime_initsig(bool preinit) { int32 i; SigTab *t; + // For c-archive/c-shared this is called by go-libmain.c with + // preinit == true. + if(runtime_isarchive && !preinit) + return; + // First call: basic setup. for(i = 0; runtime_sigtab[i].sig != -1; i++) { t = &runtime_sigtab[i]; @@ -37,6 +42,9 @@ runtime_initsig(void) } } + if(runtime_isarchive && (t->flags&SigPanic) == 0) + continue; + t->flags |= SigHandling; runtime_setsig(i, runtime_sighandler, true); } |