aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/runtime/go-signal.c')
-rw-r--r--libgo/runtime/go-signal.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
index 9fbe86e..a1215f9 100644
--- a/libgo/runtime/go-signal.c
+++ b/libgo/runtime/go-signal.c
@@ -138,6 +138,19 @@ SigTab runtime_sigtab[] = {
#undef P
#undef D
+
+static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
+
+static void
+runtime_badsignal(int32 sig)
+{
+ if (sig == SIGPROF) {
+ return; // Ignore SIGPROFs intended for a non-Go thread.
+ }
+ runtime_write(2, badsignal, sizeof badsignal - 1);
+ runtime_exit(1);
+}
+
/* Handle a signal, for cases where we don't panic. We can split the
stack here. */
@@ -146,6 +159,12 @@ sig_handler (int sig)
{
int i;
+ if (runtime_m () == NULL)
+ {
+ runtime_badsignal (sig);
+ return;
+ }
+
#ifdef SIGPROF
if (sig == SIGPROF)
{