From 68272566c6fc5e14f00516bd2890fcc3ac433c2d Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 8 May 2010 02:10:34 +0000 Subject: [PATCH] Add llvm::sys::RunInterruptHandlers(), which runs the registered SIGINT cleanup stuff. llvm-svn: 103333 --- llvm/include/llvm/System/Signals.h | 4 ++++ llvm/lib/System/Unix/Signals.inc | 4 +++- llvm/lib/System/Win32/Signals.inc | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/System/Signals.h b/llvm/include/llvm/System/Signals.h index 2b9d8ca6bf92..504420cd402d 100644 --- a/llvm/include/llvm/System/Signals.h +++ b/llvm/include/llvm/System/Signals.h @@ -20,6 +20,10 @@ namespace llvm { namespace sys { + /// This function runs all the registered interrupt handlers, including the + /// removal of files registered by RemoveFileOnSignal. + void RunInterruptHandlers(); + /// This function registers signal handlers to ensure that if a signal gets /// delivered that the named file is removed. /// @brief Remove a file if a fatal signal occurs. diff --git a/llvm/lib/System/Unix/Signals.inc b/llvm/lib/System/Unix/Signals.inc index 56bf9e76e60a..9548816e1d41 100644 --- a/llvm/lib/System/Unix/Signals.inc +++ b/llvm/lib/System/Unix/Signals.inc @@ -152,7 +152,9 @@ static RETSIGTYPE SignalHandler(int Sig) { CallBacksToRun[i].first(CallBacksToRun[i].second); } - +void llvm::sys::RunInterruptHandlers() { + SignalHandler(SIGINT); +} void llvm::sys::SetInterruptFunction(void (*IF)()) { SignalsMutex.acquire(); diff --git a/llvm/lib/System/Win32/Signals.inc b/llvm/lib/System/Win32/Signals.inc index f2b72ca70fdd..a3a393c76e45 100644 --- a/llvm/lib/System/Win32/Signals.inc +++ b/llvm/lib/System/Win32/Signals.inc @@ -189,6 +189,10 @@ static void Cleanup() { LeaveCriticalSection(&CriticalSection); } +void llvm::sys::RunInterruptHandlers() { + Cleanup(); +} + static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) { try { Cleanup();