Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 <Signal.h>

Inheritance diagram for ACE_Sig_Handler:

Inheritance graph
[legend]
Collaboration diagram for ACE_Sig_Handler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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)
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 (void) const
 Dump the state of an object.

Static Public Member Functions

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

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Static Protected Member Functions

ACE_Event_Handlerhandler_i (int signum, ACE_Event_Handler *)
int register_handler_i (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)
int in_range (int signum)
 Check whether the SIGNUM is within the legal range of signals.

Static Protected Attributes

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

Static Private Attributes

ACE_Event_Handlersignal_handlers_ [ACE_NSIG]

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.


Member Function Documentation

void ACE_Sig_Handler::dispatch int  ,
siginfo_t ,
ucontext_t
[static]
 

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

Reimplemented in ACE_Sig_Handlers.

void ACE_Sig_Handler::dump void   )  const
 

Dump the state of an object.

Reimplemented in ACE_Sig_Handlers.

ACE_Event_Handler * ACE_Sig_Handler::handler int  signum,
ACE_Event_Handler
[virtual]
 

Set a new <ace_event_handler> that is associated with <signum>. Return the existing handler.

Reimplemented in ACE_Sig_Handlers.

ACE_Event_Handler * ACE_Sig_Handler::handler int  signum  )  [virtual]
 

Return the <ace_sig_handler> associated with <signum>.

Reimplemented in ACE_Sig_Handlers.

ACE_Event_Handler * ACE_Sig_Handler::handler_i int  signum,
ACE_Event_Handler
[static, protected]
 

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

ACE_INLINE int ACE_Sig_Handler::in_range int  signum  )  [static, protected]
 

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

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.

Reimplemented in ACE_Sig_Handlers.

int ACE_Sig_Handler::register_handler_i 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
[static, protected]
 

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.

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

void ACE_Sig_Handler::sig_pending int   )  [static]
 

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

int ACE_Sig_Handler::sig_pending void   )  [static]
 

True if there is a pending signal.


Member Data Documentation

ACE_Sig_Handler::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_Sig_Handlers.

sig_atomic_t ACE_Sig_Handler::sig_pending_ = 0 [static, protected]
 

Keeps track of whether a signal is pending.

ACE_Event_Handler * ACE_Sig_Handler::signal_handlers_ [static, private]
 

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


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 20:36:44 2005 for ACE by  doxygen 1.3.9.1