summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-07 08:15:47 +0000
committerChris Lattner <sabre@nondot.org>2009-03-07 08:15:47 +0000
commit6acb4d6f7e24315e2ebf3c2b79c3e00adb21432d (patch)
tree35cbe5a6cd093e491f657f2fba8e6c4554823b40 /llvm/lib/System/Unix
parent7c22c9dcdd683ec42c86f3cd54b87f112a250426 (diff)
downloadbcm5719-llvm-6acb4d6f7e24315e2ebf3c2b79c3e00adb21432d.tar.gz
bcm5719-llvm-6acb4d6f7e24315e2ebf3c2b79c3e00adb21432d.zip
When a crash signal is delivered do two things: remove all of our
signal handlers to prevent reentrance on unrelated things (a sigabort where the handle bus errors) also, clear the signal mask so that the signal doesn't infinitely reissue. This fixes rdar://6654827 - Crash causes clang to loop llvm-svn: 66330
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Signals.inc19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/System/Unix/Signals.inc b/llvm/lib/System/Unix/Signals.inc
index f409cefcc35..94f6b6c4a39 100644
--- a/llvm/lib/System/Unix/Signals.inc
+++ b/llvm/lib/System/Unix/Signals.inc
@@ -55,13 +55,23 @@ static const int KillSigs[] = {
static const int *const KillSigsEnd =
KillSigs + sizeof(KillSigs) / sizeof(KillSigs[0]);
-// SignalHandler - The signal handler that runs...
+static void UnregisterHandler(int Signal) {
+ signal(Signal, SIG_DFL);
+}
+
+
+// SignalHandler - The signal handler that runs.
static RETSIGTYPE SignalHandler(int Sig) {
// Restore the signal behavior to default, so that the program actually
// crashes when we return and the signal reissues. This also ensures that if
// we crash in our signal handler that the program will terminate immediately
// instead of recursing in the signal handler.
- signal(Sig, SIG_DFL);
+ std::for_each(KillSigs, KillSigsEnd, UnregisterHandler);
+
+ // Unmask all potentially blocked kill signals.
+ sigset_t SigMask;
+ sigfillset(&SigMask);
+ sigprocmask(SIG_UNBLOCK, &SigMask, 0);
if (FilesToRemove != 0)
while (!FilesToRemove->empty()) {
@@ -86,12 +96,11 @@ static RETSIGTYPE SignalHandler(int Sig) {
}
// Just call signal
-static void RegisterHandler(int Signal) {
- signal(Signal, SignalHandler);
+static void RegisterHandler(int Signal) {
+ signal(Signal, SignalHandler);
}
-
void sys::SetInterruptFunction(void (*IF)()) {
InterruptFunction = IF;
RegisterHandler(SIGINT);
OpenPOWER on IntegriCloud