SyncSigHandler Class Reference

About this class. We can't call Qt functions from Unix signal handlers. We can only call async-signal-safe functions from signal handlers. So this provides a way to use Unix signal handlers with Qt. The strategy is to have our Unix signal handler will eventually cause a Qt signal to be emitted, and then we simply return from our Unix signal handler. Back in our Qt program, that Qt signal gets emitted and then received by our Qt slot function, where we are safely doing Qt stuff which weren't allowed to do in the Unix signal handler. One simple way to make this happen is declares a socket pair in our class for each Unix signal we want to handle. The socket pairs are declared as static data members.We also created a QSocketNotifier to monitor the read end of each socket pair, declare your Unix signal handlers to be static class methods, and declare a slot function corresponding to each of our Unix signal handlers. In this class, we intend to handle both the SIGHUP and SIGTERM signals. More...

`#include <SyncSigHandler.h>`

Inheritance diagram for SyncSigHandler:

## Public Slots

void | handleSigHup ()
| QT signal handler to handle SIG_HUP.
void | handleSigTerm ()
| QT signal handler to handle SIG_TERM.

## Public Member Functions

| SyncSigHandler (QObject *aParent=0, const char *aName=0)
| Constructor.
| ~SyncSigHandler ()
| Destructor.

## Static Public Member Functions

static void | hupSignalHandler (int unused)
static void | termSignalHandler (int unused)

## Detailed Description

About this class. We can't call Qt functions from Unix signal handlers. We can only call async-signal-safe functions from signal handlers. So this provides a way to use Unix signal handlers with Qt. The strategy is to have our Unix signal handler will eventually cause a Qt signal to be emitted, and then we simply return from our Unix signal handler. Back in our Qt program, that Qt signal gets emitted and then received by our Qt slot function, where we are safely doing Qt stuff which weren't allowed to do in the Unix signal handler. One simple way to make this happen is declares a socket pair in our class for each Unix signal we want to handle. The socket pairs are declared as static data members.We also created a QSocketNotifier to monitor the read end of each socket pair, declare your Unix signal handlers to be static class methods, and declare a slot function corresponding to each of our Unix signal handlers. In this class, we intend to handle both the SIGHUP and SIGTERM signals.

## Constructor & Destructor Documentation

## SyncSigHandler()

SyncSigHandler::SyncSigHandler | ( | QObject * | aParent = 0,
|  | const char * | aName = 0 )

Constructor.

Parameters

  aParent | object
  aName | const char

## Member Function Documentation

## handleSigHup

void SyncSigHandler::handleSigHup | ( |  | ) |

slot

QT signal handler to handle SIG_HUP.

Returns
  None

## handleSigTerm

void SyncSigHandler::handleSigTerm | ( |  | ) |

slot

QT signal handler to handle SIG_TERM.

Returns
  None

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

- SyncSigHandler.h
- SyncSigHandler.cpp