Image Component Library (ICL)
Static Public Member Functions | Private Member Functions | List of all members
icl::utils::SignalHandler Class Reference

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 More...
static void uninstall (const std::string &id)

Private Member Functions

 SignalHandler ()
 Create a new Signal handler with a list of signals. More...

Detailed Description

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.


class MySignalHandler : public icl::utils::SignalHandler{
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.

Constructor & Destructor Documentation

◆ SignalHandler()

icl::utils::SignalHandler::SignalHandler ( )

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.

signalscomma-separated list of string representations of the following Q_SIGNALS:
  • SIGABRT ( process abort signal)
  • SIGALRM ( Alarm clock)
  • SIGBUS ( Access to an undefined portion of a memory object)
  • SIGCHLD ( Child process terminated, stopped or continued)
  • SIGCONT ( Continue executing, if stopped)
  • SIGFPE ( Erroneous arithmetic operation)
  • SIGHUP ( Hangup )
  • SIGILL ( Illegal instruction )
  • SIGINT ( Terminal interrupt signal )
  • SIGKILL ( Kill (cannot be caught or ignored)
  • SIGPIPE ( Write on a pipe with no one to read it)
  • SIGQUIT ( Terminal quit signal )
  • SIGSEGV ( Invalid memory reference )
  • SIGSTOP ( Stop executing (cannot be caught or ignored) )
  • SIGTERM ( Termination signal )
  • SIGTSTP ( Terminal stop signal)
  • SIGTTIN ( Background process attempting read)
  • SIGTTOU ( Background process attempting write)
  • SIGUSR1 ( User-defined signal 1)
  • SIGUSR2 ( User-defined signal 2)
  • SIGPOLL ( Pollable event)
  • SIGPROF ( Profiling timer expired)
  • SIGSYS ( Bad system call)
  • SIGTRAP ( Trace/breakpoint trap )
  • SIGURG ( High bandwidth data is available at a socket)
  • SIGVTALRM ( Virtual timer expired)
  • SIGXCPU ( CPU time limit exceeded)
  • SIGXFSZ ( File size limit exceeded)

Member Function Documentation

◆ install()

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 

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!

orderPercentcan 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.

◆ uninstall()

static void icl::utils::SignalHandler::uninstall ( const std::string &  id)

The documentation for this class was generated from the following file: