LLVM API Documentation
00001 //===- llvm/System/Signals.h - Signal Handling support ----------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines some helpful functions for dealing with the possibility of 00011 // unix signals occuring while your program is running. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_SYSTEM_SIGNALS_H 00016 #define LLVM_SYSTEM_SIGNALS_H 00017 00018 #include "llvm/System/Path.h" 00019 #include "llvm/System/IncludeFile.h" 00020 00021 namespace llvm { 00022 namespace sys { 00023 00024 /// This function registers signal handlers to ensure that if a signal gets 00025 /// delivered that the named file is removed. 00026 /// @brief Remove a file if a fatal signal occurs. 00027 void RemoveFileOnSignal(const Path &Filename); 00028 00029 /// This function registers a signal handler to ensure that if a fatal signal 00030 /// gets delivered to the process that the named directory and all its 00031 /// contents are removed. 00032 /// @brief Remove a directory if a fatal signal occurs. 00033 void RemoveDirectoryOnSignal(const Path& path); 00034 00035 /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the 00036 /// process, print a stack trace and then exit. 00037 /// @brief Print a stack trace if a fatal signal occurs. 00038 void PrintStackTraceOnErrorSignal(); 00039 00040 /// This function registers a function to be called when the user "interrupts" 00041 /// the program (typically by pressing ctrl-c). When the user interrupts the 00042 /// program, the specified interrupt function is called instead of the program 00043 /// being killed, and the interrupt function automatically disabled. Note 00044 /// that interrupt functions are not allowed to call any non-reentrant 00045 /// functions. An null interrupt function pointer disables the current 00046 /// installed function. Note also that the handler may be executed on a 00047 /// different thread on some platforms. 00048 /// @brief Register a function to be called when ctrl-c is pressed. 00049 void SetInterruptFunction(void (*IF)()); 00050 } // End sys namespace 00051 } // End llvm namespace 00052 00053 FORCE_DEFINING_FILE_TO_BE_LINKED(SystemSignals) 00054 00055 #endif