aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/libgo/runtime/signal_unix.c
diff options
context:
space:
mode:
authorsynergydev <synergye@codefi.re>2013-10-17 18:16:42 -0700
committersynergydev <synergye@codefi.re>2013-10-17 18:16:42 -0700
commit61c0330cc243abf13fdd01f377a7f80bd3989eb1 (patch)
tree119b08ae76294f23e2b1b7e72ff9a06afa9e8509 /gcc-4.8/libgo/runtime/signal_unix.c
parent1c712bf7621f3859c33fd3afaa61fdcaf3fdfd76 (diff)
downloadtoolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.tar.gz
toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.tar.bz2
toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.zip
[4.8] Merge GCC 4.8.2
Change-Id: I0f1fcf69c5076d8534c5c45562745e1a37adb197
Diffstat (limited to 'gcc-4.8/libgo/runtime/signal_unix.c')
-rw-r--r--gcc-4.8/libgo/runtime/signal_unix.c103
1 files changed, 96 insertions, 7 deletions
diff --git a/gcc-4.8/libgo/runtime/signal_unix.c b/gcc-4.8/libgo/runtime/signal_unix.c
index 3b8f43937..5a506c8af 100644
--- a/gcc-4.8/libgo/runtime/signal_unix.c
+++ b/gcc-4.8/libgo/runtime/signal_unix.c
@@ -8,6 +8,7 @@
#include "runtime.h"
#include "defs.h"
+#include "signal_unix.h"
extern SigTab runtime_sigtab[];
@@ -22,7 +23,21 @@ runtime_initsig(void)
t = &runtime_sigtab[i];
if((t->flags == 0) || (t->flags & SigDefault))
continue;
- runtime_setsig(i, false, true);
+
+ // For some signals, we respect an inherited SIG_IGN handler
+ // rather than insist on installing our own default handler.
+ // Even these signals can be fetched using the os/signal package.
+ switch(t->sig) {
+ case SIGHUP:
+ case SIGINT:
+ if(runtime_getsig(i) == GO_SIG_IGN) {
+ t->flags = SigNotify | SigIgnored;
+ continue;
+ }
+ }
+
+ t->flags |= SigHandling;
+ runtime_setsig(i, runtime_sighandler, true);
}
}
@@ -32,16 +47,49 @@ runtime_sigenable(uint32 sig)
int32 i;
SigTab *t;
+ t = nil;
for(i = 0; runtime_sigtab[i].sig != -1; i++) {
- // ~0 means all signals.
- if(~sig == 0 || runtime_sigtab[i].sig == (int32)sig) {
+ if(runtime_sigtab[i].sig == (int32)sig) {
t = &runtime_sigtab[i];
- if(t->flags & SigDefault) {
- runtime_setsig(i, false, true);
- t->flags &= ~SigDefault; // make this idempotent
- }
+ break;
}
}
+
+ if(t == nil)
+ return;
+
+ if((t->flags & SigNotify) && !(t->flags & SigHandling)) {
+ t->flags |= SigHandling;
+ if(runtime_getsig(i) == GO_SIG_IGN)
+ t->flags |= SigIgnored;
+ runtime_setsig(i, runtime_sighandler, true);
+ }
+}
+
+void
+runtime_sigdisable(uint32 sig)
+{
+ int32 i;
+ SigTab *t;
+
+ t = nil;
+ for(i = 0; runtime_sigtab[i].sig != -1; i++) {
+ if(runtime_sigtab[i].sig == (int32)sig) {
+ t = &runtime_sigtab[i];
+ break;
+ }
+ }
+
+ if(t == nil)
+ return;
+
+ if((t->flags & SigNotify) && (t->flags & SigHandling)) {
+ t->flags &= ~SigHandling;
+ if(t->flags & SigIgnored)
+ runtime_setsig(i, GO_SIG_IGN, true);
+ else
+ runtime_setsig(i, GO_SIG_DFL, true);
+ }
}
void
@@ -62,3 +110,44 @@ runtime_resetcpuprofiler(int32 hz)
}
runtime_m()->profilehz = hz;
}
+
+void
+os_sigpipe(void)
+{
+ int32 i;
+
+ for(i = 0; runtime_sigtab[i].sig != -1; i++)
+ if(runtime_sigtab[i].sig == SIGPIPE)
+ break;
+ runtime_setsig(i, GO_SIG_DFL, false);
+ runtime_raise(SIGPIPE);
+}
+
+void
+runtime_crash(void)
+{
+ int32 i;
+
+#ifdef GOOS_darwin
+ // OS X core dumps are linear dumps of the mapped memory,
+ // from the first virtual byte to the last, with zeros in the gaps.
+ // Because of the way we arrange the address space on 64-bit systems,
+ // this means the OS X core file will be >128 GB and even on a zippy
+ // workstation can take OS X well over an hour to write (uninterruptible).
+ // Save users from making that mistake.
+ if(sizeof(void*) == 8)
+ return;
+#endif
+
+ for(i = 0; runtime_sigtab[i].sig != -1; i++)
+ if(runtime_sigtab[i].sig == SIGABRT)
+ break;
+ runtime_setsig(i, GO_SIG_DFL, false);
+ runtime_raise(SIGABRT);
+}
+
+void
+runtime_raise(int32 sig)
+{
+ raise(sig);
+}