diff options
author | Dan Gohman <gohman@apple.com> | 2010-05-27 23:11:55 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-05-27 23:11:55 +0000 |
commit | 288999b82959d6a057bfd478a196961215baf792 (patch) | |
tree | a7cf99f910345269cb1da3697091bb485fcc0879 /llvm/lib/System/Unix | |
parent | a817a19bc64914c3215e6ef567268dbb53453843 (diff) | |
download | bcm5719-llvm-288999b82959d6a057bfd478a196961215baf792.tar.gz bcm5719-llvm-288999b82959d6a057bfd478a196961215baf792.zip |
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.
llvm-svn: 104896
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r-- | llvm/lib/System/Unix/Signals.inc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/System/Unix/Signals.inc b/llvm/lib/System/Unix/Signals.inc index 9548816e1d4..1e74647e5fd 100644 --- a/llvm/lib/System/Unix/Signals.inc +++ b/llvm/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)()) { |