LLVM API Documentation
00001 //===- llvm/System/Signals.h - Signal Handling support ----------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // 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 00020 namespace llvm { 00021 namespace sys { 00022 00023 /// This function registers signal handlers to ensure that if a signal gets 00024 /// delivered that the named file is removed. 00025 /// @brief Remove a file if a fatal signal occurs. 00026 bool RemoveFileOnSignal(const Path &Filename, std::string* ErrMsg = 0); 00027 00028 /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the 00029 /// process, print a stack trace and then exit. 00030 /// @brief Print a stack trace if a fatal signal occurs. 00031 void PrintStackTraceOnErrorSignal(); 00032 00033 /// AddSignalHandler - Add a function to be called when an abort/kill signal 00034 /// is delivered to the process. The handler can have a cookie passed to it 00035 /// to identify what instance of the handler it is. 00036 void AddSignalHandler(void (*FnPtr)(void *), void *Cookie); 00037 00038 /// This function registers a function to be called when the user "interrupts" 00039 /// the program (typically by pressing ctrl-c). When the user interrupts the 00040 /// program, the specified interrupt function is called instead of the program 00041 /// being killed, and the interrupt function automatically disabled. Note 00042 /// that interrupt functions are not allowed to call any non-reentrant 00043 /// functions. An null interrupt function pointer disables the current 00044 /// installed function. Note also that the handler may be executed on a 00045 /// different thread on some platforms. 00046 /// @brief Register a function to be called when ctrl-c is pressed. 00047 void SetInterruptFunction(void (*IF)()); 00048 } // End sys namespace 00049 } // End llvm namespace 00050 00051 #endif