Public Member Functions | Public Attributes | Private Attributes

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

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

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = 0;

  // Since Service_Config::signal_handler_ is static and has an
  // ACE_Sig_Action instance, Win32 will get errno set unless this is
  // commented out.
#if !defined (ACE_WIN32)
  ACE_OS::sigemptyset (&this->sa_.sa_mask);
#endif /* ACE_WIN32 */
  this->sa_.sa_handler = 0;
}

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.

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = sig_flags;

  if (sig_mask == 0)
    ACE_OS::sigemptyset (&this->sa_.sa_mask);
  else
    this->sa_.sa_mask = *sig_mask; // Structure assignment...

#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */
}

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.

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = sig_flags;

  // Structure assignment...
  this->sa_.sa_mask = sig_mask.sigset ();

#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */
}

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.

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = sig_flags;

  if (sig_mask == 0)
    ACE_OS::sigemptyset (&this->sa_.sa_mask);
  else
    this->sa_.sa_mask = *sig_mask; // Structure assignment...

#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */
  ACE_OS::sigaction (signum, &this->sa_, 0);
}

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.

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = sig_flags;

  // Structure assignment...
  this->sa_.sa_mask = sig_mask.sigset ();

#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */
  ACE_OS::sigaction (signum, &this->sa_, 0);
}

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.

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = sig_flags;

  // Structure assignment...
  this->sa_.sa_mask = sig_mask.sigset ();

#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */

#if (ACE_NSIG > 0)
  for (int s = 1; s < ACE_NSIG; s++)
    if ((signals.is_member (s)) == 1)
      ACE_OS::sigaction (s, &this->sa_, 0);
#else  /* ACE_NSIG <= 0  */
  ACE_UNUSED_ARG (signals);
#endif /* ACE_NSIG <= 0  */
}

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.

{
  // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  this->sa_.sa_flags = sig_flags;

  if (sig_mask == 0)
    ACE_OS::sigemptyset (&this->sa_.sa_mask);
  else
    this->sa_.sa_mask = *sig_mask; // Structure assignment...

#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */

#if (ACE_NSIG > 0)
  for (int s = 1; s < ACE_NSIG; s++)
    if ((signals.is_member (s)) == 1)
      ACE_OS::sigaction (s, &this->sa_, 0);
#else  /* ACE_NSIG <= 0  */
  ACE_UNUSED_ARG (signals);
#endif /* ACE_NSIG <= 0  */
}

ACE_Sig_Action::ACE_Sig_Action ( const ACE_Sig_Action s  ) 

Copy constructor.

Definition at line 191 of file Signal.inl.

     : sa_ ()
{
  ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
  *this = s; // structure copy.
}

ACE_Sig_Action::~ACE_Sig_Action ( void   ) 

Default dtor.

Definition at line 33 of file Signal.cpp.

{
  ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action");
}


Member Function Documentation

void ACE_Sig_Action::dump ( void   )  const

Dump the state of an object.

Definition at line 18 of file Signal.cpp.

{
#if defined (ACE_HAS_DUMP)
  ACE_TRACE ("ACE_Sig_Action::dump");
#endif /* ACE_HAS_DUMP */
}

int ACE_Sig_Action::flags ( void   ) 

Get current signal flags.

Definition at line 100 of file Signal.inl.

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

void ACE_Sig_Action::flags ( int  flags  ) 

Set current signal flags.

Definition at line 107 of file Signal.inl.

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

struct sigaction * ACE_Sig_Action::get ( void   )  [read]

Get current signal action.

Definition at line 177 of file Signal.inl.

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

void ACE_Sig_Action::handler ( ACE_SignalHandler  handler  ) 

Set current signal handler (pointer to function).

Definition at line 143 of file Signal.inl.

{
  ACE_TRACE ("ACE_Sig_Action::handler");
#if !defined(ACE_HAS_TANDEM_SIGNALS)
  this->sa_.sa_handler = ACE_SignalHandlerV (handler);
#else
  this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (handler);
#endif /* !ACE_HAS_TANDEM_SIGNALS */
}

ACE_SignalHandler ACE_Sig_Action::handler ( void   ) 

Get current signal handler (pointer to function).

Definition at line 136 of file Signal.inl.

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

void ACE_Sig_Action::mask ( sigset_t *  ss  ) 

Set current signal mask.

Definition at line 121 of file Signal.inl.

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

void ACE_Sig_Action::mask ( ACE_Sig_Set ss  ) 

Definition at line 129 of file Signal.inl.

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

sigset_t * ACE_Sig_Action::mask ( void   ) 

Get current signal mask.

Definition at line 114 of file Signal.inl.

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

ACE_Sig_Action::operator struct sigaction * (  ) 

Definition at line 184 of file Signal.inl.

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

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.

{
  ACE_TRACE ("ACE_Sig_Action::register_action");
  struct sigaction *sa = oaction == 0 ? 0 : oaction->get ();

  return ACE_OS::sigaction (signum, &this->sa_, sa);
}

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.

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

int ACE_Sig_Action::retrieve_action ( int  signum  ) 

Retrieve the current disposition into this.

Definition at line 208 of file Signal.inl.

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

void ACE_Sig_Action::set ( struct sigaction *  sa  ) 

Set current signal action.

Definition at line 170 of file Signal.inl.

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


Member Data Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines