Image Component Library (ICL)
|
C++ Signal-Handler interface class. More...
#include <SignalHandler.h>
Static Public Member Functions | |
static void | install (const std::string &id, Function< void, const std::string & > handler, const std::string &signalList="SIGINT,SIGTERM,SIGSEGV", int orderPercent=0) |
this cannot be instantiated manually! Use SignalHandler::install instead | |
static void | uninstall (const std::string &id) |
Private Member Functions | |
SignalHandler () | |
Create a new Signal handler with a list of signals. |
C++ Signal-Handler interface class.
Just create an own signal handler class, implement its handleSignal() function and create a static object of that signal handler.
example:
class MySignalHandler : public icl::utils::SignalHandler{ public: MySignalHandler():SignalHandler("SIGINT,SIGSEGV"){} virtual void handleSignals(const string &signal){ if(signal == "SIGINT") printf("application interrupted! \n"); else printf("Oops something went wrong ...! \n"); } };
The handleSignal() function must not exit the program. This will be done auomatically.
icl::utils::SignalHandler::SignalHandler | ( | ) | [private] |
Create a new Signal handler with a list of signals.
The default parameters can be used to catch some common signals that may occur, when the program is uncommonly killed.
signals | comma-separated list of string representations of the following signals:
|
static void icl::utils::SignalHandler::install | ( | const std::string & | id, |
Function< void, const std::string & > | handler, | ||
const std::string & | signalList = "SIGINT,SIGTERM,SIGSEGV" , |
||
int | orderPercent = 0 |
||
) | [static] |
this cannot be instantiated manually! Use SignalHandler::install instead
installs a handler to the given signals! several handlers can be installed to the same signals. If a handler is installed twice under the same ID, the handler installation is skipped!
orderPercent | can be used to define an execution order of signal handlers Handlers with a higher value of orderPercent are triggered later The value 100 is used for shutting down the global QApplication, which usually ends Qt's event loop, so it should not be used. |
static void icl::utils::SignalHandler::uninstall | ( | const std::string & | id | ) | [static] |