ASSA::SigAction Class Reference

#include <SigAction.h>

List of all members.

Public Member Functions

 SigAction ()
 Default constructor creates SigAction object with null-action.
 SigAction (C_SIG_HANDLER handler_, SigSet *sig_mask_=0, int flags_=0)
 Construct a SigAction object with "C" signal handler function.
 SigAction (C_SIG_HANDLER handler_, int signum_, SigSet *sig_mask_=0, int flags_=0)
 Construct a SigAction with "C" signal handler function and change program's disposition for signum_ immediately.
int register_action (int signum_, SigAction *oaction_=0)
 Register this object as current disposition for signal signum_, and store old disposition in oaction_, if not NULL.
int restore_action (int signum_, SigAction &oaction_)
 Change object's disposition to oaction_, and install it as current disposition for the signal signum_.
int retrieve_action (int signum_)
 Retrieve current disposition for the signal signum_ into this object.
void action (SIGACTION *sa_)
 Set sigaction structure to sa_.
SIGACTIONaction ()
 Retrieve current sigaction.
void flags (int new_flags_)
 Set signal flags to new_flags_.
int flags ()
 Retrieve current flags.
void mask (SigSet &mask_set_)
 Set new signal mask mask_set_.
SigSet mask ()
 Retrieve current signal mask.
void handler (C_SIG_HANDLER sha_)
 Set new signal handler to function pointer sha_.
C_SIG_HANDLER handler ()
 Retrieve current signal handler function.
 operator SIGACTION * ()
 Conversion operator that converts SigAction to a pointer to the internal struct sigaction data member for direct use with C-library functions.

Private Attributes

SIGACTION m_sa
 sigaction structure itself


Detailed Description

Definition at line 92 of file SigAction.h.


Constructor & Destructor Documentation

ASSA::SigAction::SigAction  )  [inline]
 

Default constructor creates SigAction object with null-action.

Definition at line 219 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00220 {
00221     trace_with_mask("SigAction::SigAction", SIGACT);
00222 
00223     m_sa.sa_flags = 0;
00224     sigemptyset(&m_sa.sa_mask);
00225     *(C_SIG_HANDLER*) &m_sa.sa_handler = (C_SIG_HANDLER) 0;
00226 }

ASSA::SigAction::SigAction C_SIG_HANDLER  handler_,
SigSet sig_mask_ = 0,
int  flags_ = 0
[inline]
 

Construct a SigAction object with "C" signal handler function.

This constructor doesn't install any actions - it is merely a shell for actiono to be installed for any signal(s). Thus, you can reuse the same object for number of differen signals.

Parameters:
handler_ "C" signal handler function to call.
sig_mask_ Set of signals to block while handler_ is active.
flags_ Controls behavior of signal handler (OS-specific: see Available Options: section of documentation).

Definition at line 230 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00233 {
00234     trace_with_mask("SigAction::SigAction(,,)", SIGACT);
00235   
00236     m_sa.sa_flags = flags_;
00237     if (sig_mask_ == NULL) {
00238         sigemptyset(&m_sa.sa_mask);
00239     }
00240     else {
00241         /*---
00242           here, suppose to do bitwise structure assignment,
00243           but does it really do so?
00244           = *sig_mask_
00245              = *(sig_mask_.operator *())
00246                 = *(SigSet *tmp = &sig_mask_.m_sa) ????
00247         ---*/
00248         m_sa.sa_mask = **sig_mask_;
00249     }
00250     *(C_SIG_HANDLER*) &m_sa.sa_handler = (C_SIG_HANDLER) handler_;
00251 }

ASSA::SigAction::SigAction C_SIG_HANDLER  handler_,
int  signum_,
SigSet sig_mask_ = 0,
int  flags_ = 0
[inline]
 

Construct a SigAction with "C" signal handler function and change program's disposition for signum_ immediately.

First argument is the "C" function. It cannot be a non-static C++ class member function. This function pretty much simulates C-like approach the the signal handling. For C++ member function approach, see SigHandler & Co.

Parameters:
handler_ "C" signal handler function to call.
signum_ Signal which disposition is to change.
sig_mask_ Set of signals to block while handler_ is active.
flags_ Controls behavior of signal handler (OS-specific: see Available Options: section of documentation).

Definition at line 255 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00259 {
00260     trace_with_mask("SigAction::SigAction(,,,)", SIGACT);
00261   
00262     m_sa.sa_flags = flags_;
00263     if (sig_mask_ == NULL) {
00264         sigemptyset(&m_sa.sa_mask);
00265     }
00266     else {
00267         /*---  same problem as above... ---*/
00268         m_sa.sa_mask = **sig_mask_;
00269     }
00270     *(C_SIG_HANDLER*) &m_sa.sa_handler = (C_SIG_HANDLER) handler_;
00271     
00272     /*--- installing disposition... ---*/
00273     sigaction (signum_, &m_sa, 0);
00274 }


Member Function Documentation

SIGACTION * ASSA::SigAction::action  )  [inline]
 

Retrieve current sigaction.

Returns:
Pointer to an internal struct sigaction.

Definition at line 286 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00287 {
00288     trace_with_mask("SigAction::action", SIGACT);
00289 
00290     return &m_sa;
00291 }

void ASSA::SigAction::action SIGACTION sa_  )  [inline]
 

Set sigaction structure to sa_.

Parameters:
sa_ New value for internal struct sigaction.

Definition at line 278 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

Referenced by register_action(), and restore_action().

00279 {
00280     trace_with_mask("SigAction::action", SIGACT);
00281     m_sa = *sa_;
00282 }

int ASSA::SigAction::flags  )  [inline]
 

Retrieve current flags.

Returns:
Value of current flags for this action.

Definition at line 304 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00305 {
00306     trace_with_mask("int SigAction::flags()", SIGACT);
00307 
00308     return m_sa.sa_flags;
00309 }

void ASSA::SigAction::flags int  new_flags_  )  [inline]
 

Set signal flags to new_flags_.

Parameters:
new_flags_ New flags for this action.

Definition at line 295 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00296 {
00297     trace_with_mask("void SigAction::flags()", SIGACT);
00298 
00299     m_sa.sa_flags = new_flags_;
00300 }

C_SIG_HANDLER ASSA::SigAction::handler  )  [inline]
 

Retrieve current signal handler function.

Definition at line 341 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00342 {
00343     trace_with_mask("C_SIG_HANDLER SigAction::handler()", SIGACT);
00344 
00345     return (C_SIG_HANDLER) m_sa.sa_handler;
00346 }

void ASSA::SigAction::handler C_SIG_HANDLER  sha_  )  [inline]
 

Set new signal handler to function pointer sha_.

Definition at line 332 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

Referenced by ASSA::SigHandlers::install(), and ASSA::SigHandler::install().

00333 {
00334     trace_with_mask("void SigAction::handler()", SIGACT);
00335 
00336     *(C_SIG_HANDLER*) &m_sa.sa_handler = (C_SIG_HANDLER) sha_;
00337 }

SigSet ASSA::SigAction::mask  )  [inline]
 

Retrieve current signal mask.

Definition at line 322 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00323 {
00324     trace_with_mask("SigSet SigAction::mask()", SIGACT);
00325 
00326     SigSet tmpset(&m_sa.sa_mask);
00327     return tmpset;
00328 }

void ASSA::SigAction::mask SigSet mask_set_  )  [inline]
 

Set new signal mask mask_set_.

Definition at line 313 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00314 {
00315     trace_with_mask("void SigAction::mask()", SIGACT);
00316   
00317     m_sa.sa_mask = *mask_set_;
00318 }

ASSA::SigAction::operator SIGACTION *  )  [inline]
 

Conversion operator that converts SigAction to a pointer to the internal struct sigaction data member for direct use with C-library functions.

Definition at line 349 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

00350 {
00351     trace_with_mask("SigAction::operator SIGACTION * ()", SIGACT);
00352 
00353     return &m_sa;
00354 }

int ASSA::SigAction::register_action int  signum_,
SigAction oaction_ = 0
[inline]
 

Register this object as current disposition for signal signum_, and store old disposition in oaction_, if not NULL.

This function installs C_SIG_HANDLER this object represents, thus simulating C-like approach to signal handling.

Parameters:
signum_ Signal which disposition to install.
oaction_ Placeholder for the old disposition.
Returns:
0 on success, -1 on error, with errno indicating the error.

Definition at line 358 of file SigAction.h.

References action(), m_sa, ASSA::SIGACT, and trace_with_mask.

Referenced by ASSA::SigHandler::install(), and ASSA::SigHandler::remove().

00359 {
00360     trace_with_mask("SigAction::register_action()", SIGACT);
00361 
00362     /*--- place here recursive mutex lock to guard ... ---*/
00363     struct sigaction *osa = oaction_ == 0 ? 0 : oaction_->action();
00364     return sigaction(signum_, &m_sa, osa);
00365 }

int ASSA::SigAction::restore_action int  signum_,
SigAction oaction_
[inline]
 

Change object's disposition to oaction_, and install it as current disposition for the signal signum_.

Parameters:
signum_ Signal which disposition to restore.
oaction_ Disposition to restore.
Returns:
0 on success, -1 on error, with errno indicating the error.

Definition at line 369 of file SigAction.h.

References action(), m_sa, ASSA::SIGACT, and trace_with_mask.

00370 {
00371     trace_with_mask("SigAction::restore_action()", SIGACT);
00372 
00373     m_sa = *oaction_.action();
00374     return sigaction(signum_, &m_sa, 0);
00375 }

int ASSA::SigAction::retrieve_action int  signum_  )  [inline]
 

Retrieve current disposition for the signal signum_ into this object.

Parameters:
signum_ Signal number
Returns:
0 on success, -1 on error, with errno indicating the error.

Definition at line 379 of file SigAction.h.

References m_sa, ASSA::SIGACT, and trace_with_mask.

Referenced by ASSA::SigHandlers::install(), and ASSA::SigHandler::install().

00380 {
00381     trace_with_mask("SigAction::retrieve_action()", SIGACT);
00382 
00383     return sigaction(signum_, 0, &m_sa);
00384 }


Member Data Documentation

SIGACTION ASSA::SigAction::m_sa [private]
 

sigaction structure itself

Definition at line 211 of file SigAction.h.

Referenced by action(), flags(), handler(), mask(), operator SIGACTION *(), register_action(), restore_action(), retrieve_action(), and SigAction().


The documentation for this class was generated from the following file:
Generated on Mon Dec 19 15:59:02 2005 for libassa by  doxygen 1.4.5