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

Dan Gohman gohman at apple.com
Thu May 27 16:11:55 PDT 2010


Author: djg
Date: Thu May 27 18:11:55 2010
New Revision: 104896

URL: http://llvm.org/viewvc/llvm-project?rev=104896&view=rev
Log:
Factor out the handler work from SignalHandler into a helper function,
and change llvm::sys::RunInterruptHandlers to call that function directly
instead of calling SignalHandler, because the rest of SignalHandler
invokes side effects which aren't appropriate, including raising the
signal.

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=104896&r1=104895&r2=104896&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Signals.inc (original)
+++ llvm/trunk/lib/System/Unix/Signals.inc Thu May 27 18:11:55 2010
@@ -111,6 +111,14 @@
 }
 
 
+/// RemoveFilesToRemove - Process the FilesToRemove list. This function
+/// should be called with the SignalsMutex lock held.
+static void RemoveFilesToRemove() {
+  while (!FilesToRemove.empty()) {
+    FilesToRemove.back().eraseFromDisk(true);
+    FilesToRemove.pop_back();
+  }
+}
 
 // SignalHandler - The signal handler that runs.
 static RETSIGTYPE SignalHandler(int Sig) {
@@ -126,10 +134,7 @@
   sigprocmask(SIG_UNBLOCK, &SigMask, 0);
 
   SignalsMutex.acquire();
-  while (!FilesToRemove.empty()) {
-    FilesToRemove.back().eraseFromDisk(true);
-    FilesToRemove.pop_back();
-  }
+  RemoveFilesToRemove();
 
   if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd) {
     if (InterruptFunction) {
@@ -153,7 +158,9 @@
 }
 
 void llvm::sys::RunInterruptHandlers() {
-  SignalHandler(SIGINT);
+  SignalsMutex.acquire();
+  RemoveFilesToRemove();
+  SignalsMutex.release();
 }
 
 void llvm::sys::SetInterruptFunction(void (*IF)()) {





More information about the llvm-commits mailing list