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

This is an alternative signal handling dispatcher for ACE. It allows a list of signal handlers to be registered for each signal. It also makes SA_RESTART the default mode. More...

#include <Sig_Handler.h>

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

Public Member Functions

 ACE_Sig_Handlers ()
 Default constructor.
 
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) override
 
int remove_handler (int signum, ACE_Sig_Action *new_disp=0, ACE_Sig_Action *old_disp=0, int sigkey=-1) override
 
ACE_Event_Handlerhandler (int signum) override
 
ACE_Event_Handlerhandler (int signum, ACE_Event_Handler *) override
 
void dump () const
 Dump the state of an object.
 
- Public Member Functions inherited from ACE_Sig_Handler
 ACE_Sig_Handler ()
 Default constructor.
 
virtual ~ACE_Sig_Handler ()
 Destructor.
 
void dump () const
 Dump the state of an object.
 

Static Public Member Functions

static void dispatch (int signum, siginfo_t *, ucontext_t *)
 
- Static Public Member Functions inherited from ACE_Sig_Handler
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.
 
- Public Attributes inherited from ACE_Sig_Handler
 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.
 

Static Private Attributes

static int sigkey_ = 0
 
static bool third_party_sig_handler_ = false
 

Additional Inherited Members

- Static Protected Member Functions inherited from ACE_Sig_Handler
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 inherited from ACE_Sig_Handler
static sig_atomic_t sig_pending_ = 0
 Keeps track of whether a signal is pending.
 

Detailed Description

This is an alternative signal handling dispatcher for ACE. It allows a list of signal handlers to be registered for each signal. It also makes SA_RESTART the default mode.

Using this class a program can register one or more 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() methods of all the registered ACE_Event_Handlers are invoked automatically.

Constructor & Destructor Documentation

◆ ACE_Sig_Handlers()

ACE_Sig_Handlers::ACE_Sig_Handlers ( )

Default constructor.

Member Function Documentation

◆ dispatch()

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

Callback routine registered with sigaction(2) that dispatches the handle_signal() method of all the pre-registered ACE_Event_Handlers for signum

Master dispatcher function that gets called by a signal handler and dispatches all the handlers...

◆ dump()

void ACE_Sig_Handlers::dump ( ) const

Dump the state of an object.

◆ handler() [1/2]

ACE_Event_Handler * ACE_Sig_Handlers::handler ( int signum)
overridevirtual

Return the head of the list of ACE_Sig_Handlers associated with signum.

Return the first item in the list of handlers. Note that this will trivially provide the same behavior as the ACE_Sig_Handler version if there is only 1 handler registered!

Reimplemented from ACE_Sig_Handler.

◆ handler() [2/2]

ACE_Event_Handler * ACE_Sig_Handlers::handler ( int signum,
ACE_Event_Handler * new_sh )
overridevirtual

Set a new ACE_Event_Handler that is associated with signum at the head of the list of signals. Return the existing handler that was at the head.

The following is a strange bit of logic that tries to give the same semantics as what happens in ACE_Sig_Handler when we replace the current signal handler with a new one. Note that if there is only one signal handler the behavior will be identical. If there is more than one handler then things get weird...

Reimplemented from ACE_Sig_Handler.

◆ register_handler()

int ACE_Sig_Handlers::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 )
overridevirtual

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 a sigkey that is >= 0 on success.

This is the method that does all the dirty work... The basic structure of this method was devised by Detlef Becker.

Reimplemented from ACE_Sig_Handler.

◆ remove_handler()

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

Remove an ACE_Event_Handler currently associated with signum. We remove the handler if (1) its sigkey> matches the sigkey passed as a parameter or (2) if we've been told to remove all the handlers, i.e., sigkey == -1. If a new disposition is given it is installed and the previous disposition is returned (if desired by the caller). Returns 0 on success and -1 if signum is invalid.

Remove the ACE_Event_Handler currently associated with signum. Install the new disposition (if given) and return the previous disposition (if desired by the caller). Returns 0 on success and

Reimplemented from ACE_Sig_Handler.

Member Data Documentation

◆ ACE_ALLOC_HOOK_DECLARE

ACE_Sig_Handlers::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

◆ sigkey_

int ACE_Sig_Handlers::sigkey_ = 0
staticprivate

Keeps track of the id that uniquely identifies each registered signal handler. This id can be used to cancel a timer via the remove_handler() method.

Keeps track of the id that uniquely identifies each registered signal handler. This id can be used to cancel a timer via the <remove_handler> method.

◆ third_party_sig_handler_

bool ACE_Sig_Handlers::third_party_sig_handler_ = false
staticprivate

If this is true then a 3rd party library has registered a handler...


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