[llvm-commits] CVS: llvm/lib/System/Unix/Signals.inc
Chris Lattner
lattner at cs.uiuc.edu
Mon Aug 1 19:14:34 PDT 2005
Changes in directory llvm/lib/System/Unix:
Signals.inc updated: 1.9 -> 1.10
---
Log message:
Implement sys::SetInterruptFunction on Unix, stub it on win32 so that the
build will not fail
---
Diffs of the changes: (+18 -2)
Signals.inc | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
Index: llvm/lib/System/Unix/Signals.inc
diff -u llvm/lib/System/Unix/Signals.inc:1.9 llvm/lib/System/Unix/Signals.inc:1.10
--- llvm/lib/System/Unix/Signals.inc:1.9 Thu Jul 7 22:08:58 2005
+++ llvm/lib/System/Unix/Signals.inc Mon Aug 1 21:14:22 2005
@@ -24,6 +24,9 @@
namespace {
+/// InterruptFunction - The function to call if ctrl-c is pressed.
+void (*InterruptFunction)() = 0;
+
std::vector<std::string> *FilesToRemove = 0 ;
std::vector<llvm::sys::Path> *DirectoriesToRemove = 0;
@@ -116,8 +119,16 @@
DirectoriesToRemove->pop_back();
}
- if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd)
- exit(1); // If this is an interrupt signal, exit the program
+ if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd) {
+ if (InterruptFunction) {
+ void (*IF)() = InterruptFunction;
+ InterruptFunction = 0;
+ IF(); // run the interrupt function.
+ return;
+ } else {
+ exit(1); // If this is an interrupt signal, exit the program
+ }
+ }
// Otherwise if it is a fault (like SEGV) output the stacktrace to
// STDERR (if we can) and reissue the signal to die...
@@ -134,6 +145,11 @@
namespace llvm {
+void sys::SetInterruptFunction(void (*IF)()) {
+ InterruptFunction = IF;
+ RegisterHandler(SIGINT);
+}
+
// RemoveFileOnSignal - The public API
void sys::RemoveFileOnSignal(const sys::Path &Filename) {
if (FilesToRemove == 0)
More information about the llvm-commits
mailing list