[llvm-commits] [llvm] r66171 - /llvm/trunk/lib/System/Unix/Signals.inc

Chris Lattner sabre at nondot.org
Thu Mar 5 10:22:14 PST 2009


Author: lattner
Date: Thu Mar  5 12:22:14 2009
New Revision: 66171

URL: http://llvm.org/viewvc/llvm-project?rev=66171&view=rev
Log:
move some code to gracefully handle the case when a handler crashes.

Modified:
    llvm/trunk/lib/System/Unix/Signals.inc

Modified: llvm/trunk/lib/System/Unix/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Signals.inc?rev=66171&r1=66170&r2=66171&view=diff

==============================================================================
--- llvm/trunk/lib/System/Unix/Signals.inc (original)
+++ llvm/trunk/lib/System/Unix/Signals.inc Thu Mar  5 12:22:14 2009
@@ -57,6 +57,12 @@
 
 // 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);
+
   if (FilesToRemove != 0)
     while (!FilesToRemove->empty()) {
       FilesToRemove->back().eraseFromDisk(true);
@@ -77,10 +83,6 @@
   if (CallBacksToRun)
     for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i)
       (*CallBacksToRun)[i].first((*CallBacksToRun)[i].second);
-    
-  // Restore the signal behavior to default, so that the program actually
-  // crashes when we return and the signal reissues.
-  signal(Sig, SIG_DFL);
 }
 
 // Just call signal





More information about the llvm-commits mailing list