summaryrefslogtreecommitdiff
path: root/lib/System
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-27 23:11:55 +0000
committerDan Gohman <gohman@apple.com>2010-05-27 23:11:55 +0000
commit39f76bb6c8d6e7edb77805f770318ebd1727d0aa (patch)
treee6ec5787c661d84a78540c2de23417ebeffd5151 /lib/System
parent84f60b7359e1aa90794bb19de2bbf4d25dc2f01d (diff)
downloadllvm-39f76bb6c8d6e7edb77805f770318ebd1727d0aa.tar.gz
llvm-39f76bb6c8d6e7edb77805f770318ebd1727d0aa.tar.bz2
llvm-39f76bb6c8d6e7edb77805f770318ebd1727d0aa.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Unix/Signals.inc17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/System/Unix/Signals.inc b/lib/System/Unix/Signals.inc
index 9548816e1d..1e74647e5f 100644
--- a/lib/System/Unix/Signals.inc
+++ b/lib/System/Unix/Signals.inc
@@ -111,6 +111,14 @@ static void UnregisterHandlers() {
}
+/// 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 @@ static RETSIGTYPE SignalHandler(int Sig) {
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 @@ static RETSIGTYPE SignalHandler(int Sig) {
}
void llvm::sys::RunInterruptHandlers() {
- SignalHandler(SIGINT);
+ SignalsMutex.acquire();
+ RemoveFilesToRemove();
+ SignalsMutex.release();
}
void llvm::sys::SetInterruptFunction(void (*IF)()) {