ACE_Sig_Action Class Reference

C++ wrapper facade for the sigaction struct. More...

#include <Signal.h>

List of all members.

Public Member Functions

 ACE_Sig_Action (void)
 Default constructor. Initializes everything to 0.
 ACE_Sig_Action (ACE_SignalHandler handler, sigset_t *sigmask=0, int flags=0)
 ACE_Sig_Action (ACE_SignalHandler handler, const ACE_Sig_Set &sigmask, int flags=0)
 ACE_Sig_Action (ACE_SignalHandler handler, int signum, sigset_t *sigmask=0, int flags=0)
 ACE_Sig_Action (ACE_SignalHandler handler, int signum, const ACE_Sig_Set &sigmask, int flags=0)
 ACE_Sig_Action (const ACE_Sig_Set &signalss, ACE_SignalHandler handler, const ACE_Sig_Set &sigmask, int flags=0)
 ACE_Sig_Action (const ACE_Sig_Set &signalss, ACE_SignalHandler handler, sigset_t *sigmask=0, int flags=0)
 ACE_Sig_Action (const ACE_Sig_Action &s)
 Copy constructor.
 ~ACE_Sig_Action (void)
 Default dtor.
int register_action (int signum, ACE_Sig_Action *oaction=0)
int restore_action (int signum, ACE_Sig_Action &oaction)
int retrieve_action (int signum)
 Retrieve the current disposition into this.
void set (struct sigaction *)
 Set current signal action.
sigaction * get (void)
 Get current signal action.
 operator struct sigaction * ()
void flags (int)
 Set current signal flags.
int flags (void)
 Get current signal flags.
void mask (sigset_t *)
 Set current signal mask.
void mask (ACE_Sig_Set &)
sigset_t * mask (void)
 Get current signal mask.
void handler (ACE_SignalHandler)
 Set current signal handler (pointer to function).
ACE_SignalHandler handler (void)
 Get current signal handler (pointer to function).
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Attributes

sigaction sa_
 Controls signal behavior.


Detailed Description

C++ wrapper facade for the sigaction struct.

Definition at line 100 of file Signal.h.


Constructor & Destructor Documentation

ACE_Sig_Action::ACE_Sig_Action ( void   ) 

Default constructor. Initializes everything to 0.

Definition at line 77 of file Signal.cpp.

References sa_, and ACE_OS::sigemptyset().

00078 {
00079   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00080   this->sa_.sa_flags = 0;
00081 
00082   // Since Service_Config::signal_handler_ is static and has an
00083   // ACE_Sig_Action instance, Win32 will get errno set unless this is
00084   // commented out.
00085 #if !defined (ACE_WIN32)
00086   ACE_OS::sigemptyset (&this->sa_.sa_mask);
00087 #endif /* ACE_WIN32 */
00088   this->sa_.sa_handler = 0;
00089 }

ACE_Sig_Action::ACE_Sig_Action ( ACE_SignalHandler  handler,
sigset_t *  sigmask = 0,
int  flags = 0 
)

Assigns the various fields of a sigaction struct but doesn't register for signal handling via the sigaction function.

Definition at line 91 of file Signal.cpp.

References sa_, and ACE_OS::sigemptyset().

00094 {
00095   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00096   this->sa_.sa_flags = sig_flags;
00097 
00098   if (sig_mask == 0)
00099     ACE_OS::sigemptyset (&this->sa_.sa_mask);
00100   else
00101     this->sa_.sa_mask = *sig_mask; // Structure assignment...
00102 
00103 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00104   this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
00105 #else
00106   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
00107 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00108 }

ACE_Sig_Action::ACE_Sig_Action ( ACE_SignalHandler  handler,
const ACE_Sig_Set sigmask,
int  flags = 0 
)

Assigns the various fields of a sigaction struct but doesn't register for signal handling via the sigaction function.

Definition at line 110 of file Signal.cpp.

References sa_, and ACE_Sig_Set::sigset().

00113 {
00114   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00115   this->sa_.sa_flags = sig_flags;
00116 
00117   // Structure assignment...
00118   this->sa_.sa_mask = sig_mask.sigset ();
00119 
00120 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00121   this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
00122 #else
00123   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
00124 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00125 }

ACE_Sig_Action::ACE_Sig_Action ( ACE_SignalHandler  handler,
int  signum,
sigset_t *  sigmask = 0,
int  flags = 0 
)

Assigns the various fields of a sigaction struct and registers the handler to process signal signum via the sigaction function.

Definition at line 127 of file Signal.cpp.

References sa_, ACE_OS::sigaction(), and ACE_OS::sigemptyset().

00131 {
00132   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00133   this->sa_.sa_flags = sig_flags;
00134 
00135   if (sig_mask == 0)
00136     ACE_OS::sigemptyset (&this->sa_.sa_mask);
00137   else
00138     this->sa_.sa_mask = *sig_mask; // Structure assignment...
00139 
00140 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00141   this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
00142 #else
00143   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
00144 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00145   ACE_OS::sigaction (signum, &this->sa_, 0);
00146 }

ACE_Sig_Action::ACE_Sig_Action ( ACE_SignalHandler  handler,
int  signum,
const ACE_Sig_Set sigmask,
int  flags = 0 
)

Assigns the various fields of a sigaction struct and registers the handler to process signal signum via the sigaction function.

Definition at line 148 of file Signal.cpp.

References sa_, ACE_OS::sigaction(), and ACE_Sig_Set::sigset().

00152 {
00153   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00154   this->sa_.sa_flags = sig_flags;
00155 
00156   // Structure assignment...
00157   this->sa_.sa_mask = sig_mask.sigset ();
00158 
00159 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00160   this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
00161 #else
00162   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
00163 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00164   ACE_OS::sigaction (signum, &this->sa_, 0);
00165 }

ACE_Sig_Action::ACE_Sig_Action ( const ACE_Sig_Set signalss,
ACE_SignalHandler  handler,
const ACE_Sig_Set sigmask,
int  flags = 0 
)

Assigns the various fields of a sigaction struct and registers the handler to process all signalss via the sigaction function.

Definition at line 167 of file Signal.cpp.

References ACE_NSIG, ACE_Sig_Set::is_member(), sa_, ACE_OS::sigaction(), and ACE_Sig_Set::sigset().

00171 {
00172   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00173   this->sa_.sa_flags = sig_flags;
00174 
00175   // Structure assignment...
00176   this->sa_.sa_mask = sig_mask.sigset ();
00177 
00178 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00179   this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
00180 #else
00181   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
00182 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00183 
00184 #if (ACE_NSIG > 0)
00185   for (int s = 1; s < ACE_NSIG; s++)
00186     if ((signals.is_member (s)) == 1)
00187       ACE_OS::sigaction (s, &this->sa_, 0);
00188 #else  /* ACE_NSIG <= 0  */
00189   ACE_UNUSED_ARG (signals);
00190 #endif /* ACE_NSIG <= 0  */
00191 }

ACE_Sig_Action::ACE_Sig_Action ( const ACE_Sig_Set signalss,
ACE_SignalHandler  handler,
sigset_t *  sigmask = 0,
int  flags = 0 
)

Assigns the various fields of a sigaction struct and registers the handler to process all signalss via the sigaction function.

Definition at line 193 of file Signal.cpp.

References ACE_NSIG, ACE_Sig_Set::is_member(), sa_, ACE_OS::sigaction(), and ACE_OS::sigemptyset().

00197 {
00198   // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00199   this->sa_.sa_flags = sig_flags;
00200 
00201   if (sig_mask == 0)
00202     ACE_OS::sigemptyset (&this->sa_.sa_mask);
00203   else
00204     this->sa_.sa_mask = *sig_mask; // Structure assignment...
00205 
00206 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00207   this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
00208 #else
00209   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
00210 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00211 
00212 #if (ACE_NSIG > 0)
00213   for (int s = 1; s < ACE_NSIG; s++)
00214     if ((signals.is_member (s)) == 1)
00215       ACE_OS::sigaction (s, &this->sa_, 0);
00216 #else  /* ACE_NSIG <= 0  */
00217   ACE_UNUSED_ARG (signals);
00218 #endif /* ACE_NSIG <= 0  */
00219 }

ACE_INLINE ACE_Sig_Action::ACE_Sig_Action ( const ACE_Sig_Action s  ) 

Copy constructor.

Definition at line 191 of file Signal.inl.

References ACE_TRACE.

00192      : sa_ ()
00193 {
00194   ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00195   *this = s; // structure copy.
00196 }

ACE_Sig_Action::~ACE_Sig_Action ( void   ) 

Default dtor.

Definition at line 33 of file Signal.cpp.

References ACE_TRACE.

00034 {
00035   ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action");
00036 }


Member Function Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_Sig_Action::dump ( void   )  const

Dump the state of an object.

Definition at line 18 of file Signal.cpp.

References ACE_TRACE.

00019 {
00020 #if defined (ACE_HAS_DUMP)
00021   ACE_TRACE ("ACE_Sig_Action::dump");
00022 #endif /* ACE_HAS_DUMP */
00023 }

ACE_INLINE int ACE_Sig_Action::flags ( void   ) 

Get current signal flags.

Definition at line 100 of file Signal.inl.

References ACE_TRACE, and sa_.

00101 {
00102   ACE_TRACE ("ACE_Sig_Action::flags");
00103   return this->sa_.sa_flags;
00104 }

ACE_INLINE void ACE_Sig_Action::flags ( int   ) 

Set current signal flags.

Definition at line 107 of file Signal.inl.

References ACE_TRACE, and sa_.

Referenced by ACE_Sig_Handlers::register_handler(), and ACE_Sig_Handler::register_handler_i().

00108 {
00109   ACE_TRACE ("ACE_Sig_Action::flags");
00110   this->sa_.sa_flags = flags;
00111 }

ACE_INLINE struct sigaction * ACE_Sig_Action::get ( void   ) 

Get current signal action.

Definition at line 177 of file Signal.inl.

References ACE_TRACE, and sa_.

Referenced by register_action(), and restore_action().

00178 {
00179   ACE_TRACE ("ACE_Sig_Action::get");
00180   return &this->sa_;
00181 }

ACE_INLINE ACE_SignalHandler ACE_Sig_Action::handler ( void   ) 

Get current signal handler (pointer to function).

Definition at line 136 of file Signal.inl.

References ACE_TRACE.

00137 {
00138   ACE_TRACE ("ACE_Sig_Action::handler");
00139   return ACE_SignalHandler (this->sa_.sa_handler);
00140 }

ACE_INLINE void ACE_Sig_Action::handler ( ACE_SignalHandler   ) 

Set current signal handler (pointer to function).

Definition at line 143 of file Signal.inl.

References ACE_TRACE, and sa_.

Referenced by ACE_Sig_Handlers::register_handler(), and ACE_Sig_Handler::register_handler_i().

00144 {
00145   ACE_TRACE ("ACE_Sig_Action::handler");
00146 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00147   this->sa_.sa_handler = ACE_SignalHandlerV (handler);
00148 #else
00149   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (handler);
00150 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00151 }

ACE_INLINE sigset_t * ACE_Sig_Action::mask ( void   ) 

Get current signal mask.

Definition at line 114 of file Signal.inl.

References ACE_TRACE, and sa_.

00115 {
00116   ACE_TRACE ("ACE_Sig_Action::mask");
00117   return &this->sa_.sa_mask;
00118 }

ACE_INLINE void ACE_Sig_Action::mask ( ACE_Sig_Set  ) 

Definition at line 129 of file Signal.inl.

References ACE_TRACE, sa_, and ACE_Sig_Set::sigset().

00130 {
00131   ACE_TRACE ("ACE_Sig_Action::mask");
00132   this->sa_.sa_mask = ss.sigset (); // Structure assignment
00133 }

ACE_INLINE void ACE_Sig_Action::mask ( sigset_t *   ) 

Set current signal mask.

Definition at line 121 of file Signal.inl.

References ACE_TRACE, and sa_.

00122 {
00123   ACE_TRACE ("ACE_Sig_Action::mask");
00124   if (ss != 0)
00125     this->sa_.sa_mask = *ss; // Structure assignment
00126 }

ACE_INLINE ACE_Sig_Action::operator struct sigaction * (  ) 

Definition at line 184 of file Signal.inl.

References ACE_TRACE, and sa_.

00185 {
00186   ACE_TRACE ("ACE_Sig_Action::operator struct sigaction *");
00187   return &this->sa_;
00188 }

ACE_INLINE int ACE_Sig_Action::register_action ( int  signum,
ACE_Sig_Action oaction = 0 
)

Register this as the current disposition and store old disposition into oaction if it is non-NULL.

Definition at line 199 of file Signal.inl.

References ACE_TRACE, get(), and ACE_OS::sigaction().

Referenced by ACE_Sig_Adapter::handle_signal(), ACE_Sig_Handlers::register_handler(), ACE_Sig_Handler::register_handler_i(), ACE_Sig_Handlers::remove_handler(), ACE_Sig_Handler::remove_handler(), ACE_Process_Manager::wait(), and ACE_Process::wait().

00200 {
00201   ACE_TRACE ("ACE_Sig_Action::register_action");
00202   struct sigaction *sa = oaction == 0 ? 0 : oaction->get ();
00203 
00204   return ACE_OS::sigaction (signum, &this->sa_, sa);
00205 }

ACE_INLINE int ACE_Sig_Action::restore_action ( int  signum,
ACE_Sig_Action oaction 
)

Assign the value of oaction to this and make it become the new signal disposition.

Definition at line 215 of file Signal.inl.

References ACE_TRACE, get(), sa_, and ACE_OS::sigaction().

00216 {
00217   ACE_TRACE ("ACE_Sig_Action::restore_action");
00218   this->sa_ = *oaction.get (); // Structure assignment
00219   return ACE_OS::sigaction (signum, &this->sa_, 0);
00220 }

ACE_INLINE int ACE_Sig_Action::retrieve_action ( int  signum  ) 

Retrieve the current disposition into this.

Definition at line 208 of file Signal.inl.

References ACE_TRACE, and ACE_OS::sigaction().

Referenced by ACE_Sig_Handlers::register_handler().

00209 {
00210   ACE_TRACE ("ACE_Sig_Action::retrieve_action");
00211   return ACE_OS::sigaction (signum, 0, &this->sa_);
00212 }

ACE_INLINE void ACE_Sig_Action::set ( struct sigaction *   ) 

Set current signal action.

Definition at line 170 of file Signal.inl.

References ACE_TRACE, and sa_.

00171 {
00172   ACE_TRACE ("ACE_Sig_Action::set");
00173   this->sa_ = *sa; // Structure assignment.
00174 }


Member Data Documentation

ACE_Sig_Action::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Definition at line 221 of file Signal.h.

struct sigaction ACE_Sig_Action::sa_ [private]

Controls signal behavior.

Definition at line 225 of file Signal.h.

Referenced by ACE_Sig_Action(), flags(), get(), handler(), mask(), operator struct sigaction *(), restore_action(), and set().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:36 2010 for ACE by  doxygen 1.4.7