ACE 8.0.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Protected Member Functions | Static Protected Attributes | Static Private Attributes | List of all members
ACE_Sig_Handler Class Reference

This is the main dispatcher of signals for ACE. It improves the existing UNIX signal handling mechanism by allowing C++ objects to handle signals in a way that avoids the use of global/static variables and functions. More...

#include <Sig_Handler.h>

Inheritance diagram for ACE_Sig_Handler:
Inheritance graph
[legend]
Collaboration diagram for ACE_Sig_Handler:
Collaboration graph
[legend]

Public Member Functions

 ACE_Sig_Handler ()
 Default constructor.
 
virtual ~ACE_Sig_Handler ()
 Destructor.
 
virtual int register_handler (int signum, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp=0, ACE_Event_Handler **old_sh=0, ACE_Sig_Action *old_disp=0)
 
virtual int remove_handler (int signum, ACE_Sig_Action *new_disp=0, ACE_Sig_Action *old_disp=0, int sigkey=-1)
 Remove an ACE_Event_Handler.
 
virtual ACE_Event_Handlerhandler (int signum)
 Return the ACE_Sig_Handler associated with signum.
 
virtual ACE_Event_Handlerhandler (int signum, ACE_Event_Handler *)
 
void dump () const
 Dump the state of an object.
 

Static Public Member Functions

static int sig_pending ()
 True if there is a pending signal.
 
static void sig_pending (int)
 Reset the value of sig_pending_ so that no signal is pending.
 
static void dispatch (int, siginfo_t *, ucontext_t *)
 

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.
 

Static Protected Member Functions

static ACE_Event_Handlerhandler_i (int signum, ACE_Event_Handler *)
 
static int register_handler_i (int signum, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp=nullptr, ACE_Event_Handler **old_sh=nullptr, ACE_Sig_Action *old_disp=nullptr)
 
static int remove_handler_i (int signum, ACE_Sig_Action *new_disp=nullptr, ACE_Sig_Action *old_disp=nullptr, int sigkey=-1)
 
static int in_range (int signum)
 Check whether the SIGNUM is within the legal range of signals.
 

Static Protected Attributes

static sig_atomic_t sig_pending_ = 0
 Keeps track of whether a signal is pending.
 

Static Private Attributes

static ACE_Event_Handlersignal_handlers_ [ACE_NSIG]
 Array of Event_Handlers that will handle the signals.
 

Detailed Description

This is the main dispatcher of signals for ACE. It improves the existing UNIX signal handling mechanism by allowing C++ objects to handle signals in a way that avoids the use of global/static variables and functions.

Using this class a program can register an ACE_Event_Handler with the ACE_Sig_Handler in order to handle a designated signum. When a signal occurs that corresponds to this signum, the handle_signal method of the registered ACE_Event_Handler is invoked automatically.

Constructor & Destructor Documentation

◆ ACE_Sig_Handler()

ACE_Sig_Handler::ACE_Sig_Handler ( )
inline

Default constructor.

◆ ~ACE_Sig_Handler()

ACE_Sig_Handler::~ACE_Sig_Handler ( )
virtual

Destructor.

Member Function Documentation

◆ dispatch()

void ACE_Sig_Handler::dispatch ( int signum,
siginfo_t * siginfo,
ucontext_t * ucontext )
static

Callback routine registered with sigaction(2) that dispatches the handle_signal() method of the appropriate pre-registered ACE_Event_Handler.

Master dispatcher function that gets called by a signal handler and dispatches one handler...

◆ dump()

void ACE_Sig_Handler::dump ( ) const

Dump the state of an object.

◆ handler() [1/2]

ACE_Event_Handler * ACE_Sig_Handler::handler ( int signum)
virtual

Return the ACE_Sig_Handler associated with signum.

Reimplemented in ACE_Sig_Handlers.

◆ handler() [2/2]

ACE_Event_Handler * ACE_Sig_Handler::handler ( int signum,
ACE_Event_Handler * new_sh )
virtual

Set a new ACE_Event_Handler that is associated with signum. Return the existing handler.

Reimplemented in ACE_Sig_Handlers.

◆ handler_i()

ACE_Event_Handler * ACE_Sig_Handler::handler_i ( int signum,
ACE_Event_Handler * new_sh )
staticprotected

Set a new ACE_Event_Handler that is associated with signum. Return the existing handler. Does not acquire any locks so that it can be called from a signal handler, such as dispatch().

◆ in_range()

int ACE_Sig_Handler::in_range ( int signum)
inlinestaticprotected

Check whether the SIGNUM is within the legal range of signals.

◆ register_handler()

int ACE_Sig_Handler::register_handler ( int signum,
ACE_Event_Handler * new_sh,
ACE_Sig_Action * new_disp = 0,
ACE_Event_Handler ** old_sh = 0,
ACE_Sig_Action * old_disp = 0 )
virtual

Add a new ACE_Event_Handler and a new sigaction associated with signum. Passes back the existing ACE_Event_Handler and its sigaction if pointers are non-zero. Returns -1 on failure and >= 0 on success.

Register an ACE_Event_Handler along with the corresponding SIGNUM. This method acquires a lock, so it can't be called from a signal handler, e.g., <dispatch>.

Reimplemented in ACE_Sig_Handlers.

◆ register_handler_i()

int ACE_Sig_Handler::register_handler_i ( int signum,
ACE_Event_Handler * new_sh,
ACE_Sig_Action * new_disp = nullptr,
ACE_Event_Handler ** old_sh = nullptr,
ACE_Sig_Action * old_disp = nullptr )
staticprotected

This implementation method is called by register_handler() and dispatch. It doesn't do any locking so that it can be called within a signal handler, such as dispatch. It adds a new ACE_Event_Handler and a new sigaction associated with signum. Passes back the existing ACE_Event_Handler and its sigaction if pointers are non-zero. Returns -1 on failure and >= 0 on success.

Register an ACE_Event_Handler along with the corresponding SIGNUM. This method does NOT acquire any locks, so it can be called from a signal handler.

◆ remove_handler()

int ACE_Sig_Handler::remove_handler ( int signum,
ACE_Sig_Action * new_disp = 0,
ACE_Sig_Action * old_disp = 0,
int sigkey = -1 )
virtual

Remove an ACE_Event_Handler.

Remove the ACE_Event_Handler currently associated with signum. sigkey is ignored in this implementation since there is only one instance of a signal handler. Install the new disposition (if given) and return the previous disposition (if desired by the caller). Returns 0 on success and -1 if signum is invalid.

Reimplemented in ACE_Sig_Handlers.

◆ remove_handler_i()

int ACE_Sig_Handler::remove_handler_i ( int signum,
ACE_Sig_Action * new_disp = nullptr,
ACE_Sig_Action * old_disp = nullptr,
int sigkey = -1 )
staticprotected

◆ sig_pending() [1/2]

int ACE_Sig_Handler::sig_pending ( )
static

True if there is a pending signal.

◆ sig_pending() [2/2]

void ACE_Sig_Handler::sig_pending ( int pending)
static

Reset the value of sig_pending_ so that no signal is pending.

Member Data Documentation

◆ ACE_ALLOC_HOOK_DECLARE

ACE_Sig_Handler::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

◆ sig_pending_

sig_atomic_t ACE_Sig_Handler::sig_pending_ = 0
staticprotected

Keeps track of whether a signal is pending.

Remembers if a signal has occurred.

◆ signal_handlers_

ACE_Event_Handler * ACE_Sig_Handler::signal_handlers_
staticprivate

Array of Event_Handlers that will handle the signals.

Array used to store one user-defined Event_Handler for every signal.


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