Public Types | Static Public Member Functions | Static Public Attributes

base::Signal Class Reference

Global signal handling. More...

#include <libppbase/base/Signal.h>

List of all members.

Public Types

typedef void(* ioEventHandler )(int, int, void *)
 event handler for io events

Static Public Member Functions

static void handle (int sig, void(*handler)(int))
 Handles a signal by a custom signal handler.
static void handle (int sig)
 Handles a signal by the built-in signal handler.
static void ignore (int sig)
 Ignores a signal permanently.
static void setDefaults ()
 Registers the built-in signal handler for the most important signals.
static void signal_handler (int sig)
 The signal handler, may be called from outside.
static void addEventHandler (int fd, ioEventHandler handler, void *user)
 Adds an event handler.
static void delEventHandler (int fd)
 Removes an event handler.
static void handleIO (int sig=SIGIO)
 Installs a signal handler that handles IO signals.
static void handleIOEvents ()
 Handle I/O events.
static void handlerIO (int sig, siginfo_t *info, void *ctx)
 Signal handler.

Static Public Attributes

static volatile int _alarm
 number of alarm signals received
static volatile int _child
 number of child signals received
static volatile int _quit
 number of int, term or quit signals received
static volatile int _restart
 number of quit signals received
static volatile int _reread
 number of hup signals received
static volatile int _user1
 number of user 1 signals received
static volatile int _user2
 number of user 2 signals received
static std::map< int,
std::pair< ioEventHandler,
void * > > 
_ioeh
 List of event handlers (fd, (handler, user)).

Detailed Description

Global signal handling.

It is recommended to call the setDefaults method only, as this sets default signal handlers. The application may examine the global variables to find out whether a signal has been delivered.

Author:
Christoph Schwarz
Version:
$Id: Signal.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Function Documentation

static void base::Signal::addEventHandler ( int  fd,
ioEventHandler  handler,
void *  user 
) [static]

Adds an event handler.

Parameters:
fd file descriptor
handler the handler
user user data
static void base::Signal::delEventHandler ( int  fd  )  [static]

Removes an event handler.

Parameters:
fd file descriptor
static void base::Signal::handle ( int  sig  )  [static]

Handles a signal by the built-in signal handler.

Parameters:
sig the signal to handle
static void base::Signal::handle ( int  sig,
void(*)(int)  handler 
) [static]

Handles a signal by a custom signal handler.

Parameters:
sig the signal
handler the signal handler
static void base::Signal::handleIO ( int  sig = SIGIO  )  [static]

Installs a signal handler that handles IO signals.

Parameters:
sig the signal to install the handler for
static void base::Signal::handlerIO ( int  sig,
siginfo_t *  info,
void *  ctx 
) [static]

Signal handler.

Parameters:
sig signal number
info signal information
ctx user context
static void base::Signal::ignore ( int  sig  )  [static]

Ignores a signal permanently.

Parameters:
sig the signal to ignore
static void base::Signal::setDefaults (  )  [static]

Registers the built-in signal handler for the most important signals.

On the Win32 platform this also registers the calling thread as receiver for a WM_QUIT message. The signal handler sends this message whenever it catches a signal. Use setThreadMsg() to inhibit message sending or to set a different message to send.


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