Signal.cpp

Go to the documentation of this file.
00001 // $Id: Signal.cpp 80826 2008-03-04 14:51:23Z wotte $
00002 
00003 #include "ace/Signal.h"
00004 // #include "ace/Log_Msg.h"
00005 
00006 #if !defined (__ACE_INLINE__)
00007 #include "ace/Signal.inl"
00008 #endif /* __ACE_INLINE__ */
00009 
00010 ACE_RCSID(ace, Signal, "$Id: Signal.cpp 80826 2008-03-04 14:51:23Z wotte $")
00011 
00012 
00013 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Action)
00016 
00017 void
00018 ACE_Sig_Action::dump (void) const
00019 {
00020 #if defined (ACE_HAS_DUMP)
00021   ACE_TRACE ("ACE_Sig_Action::dump");
00022 #endif /* ACE_HAS_DUMP */
00023 }
00024 
00025 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Set)
00026 
00027 ACE_Sig_Set::~ACE_Sig_Set (void)
00028 {
00029   ACE_TRACE ("ACE_Sig_Set::~ACE_Sig_Set");
00030   ACE_OS::sigemptyset (&this->sigset_);
00031 }
00032 
00033 ACE_Sig_Action::~ACE_Sig_Action (void)
00034 {
00035   ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action");
00036 }
00037 
00038 // Restore the signal mask.
00039 
00040 ACE_Sig_Guard::~ACE_Sig_Guard (void)
00041 {
00042   //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard");
00043   if (!this->condition_)
00044     return;
00045 
00046 #if !defined (ACE_LACKS_UNIX_SIGNALS)
00047 #if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
00048   ACE_OS::sigprocmask (SIG_SETMASK,
00049                        (sigset_t *) this->omask_,
00050                        0);
00051 #else
00052   ACE_OS::thr_sigsetmask (SIG_SETMASK,
00053                           (sigset_t *) this->omask_,
00054                           0);
00055 #endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
00056 #endif /* !ACE_LACKS_UNIX_SIGNALS */
00057 }
00058 
00059 void
00060 ACE_Sig_Set::dump (void) const
00061 {
00062 #if defined (ACE_HAS_DUMP)
00063   ACE_TRACE ("ACE_Sig_Set::dump");
00064 #endif /* ACE_HAS_DUMP */
00065 }
00066 
00067 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Guard)
00068 
00069 void
00070 ACE_Sig_Guard::dump (void) const
00071 {
00072 #if defined (ACE_HAS_DUMP)
00073   ACE_TRACE ("ACE_Sig_Guard::dump");
00074 #endif /* ACE_HAS_DUMP */
00075 }
00076 
00077 ACE_Sig_Action::ACE_Sig_Action (void)
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 }
00090 
00091 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
00092                                 sigset_t *sig_mask,
00093                                 int sig_flags)
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 }
00109 
00110 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
00111                                 const ACE_Sig_Set &sig_mask,
00112                                 int sig_flags)
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 }
00126 
00127 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
00128                                 int signum,
00129                                 sigset_t *sig_mask,
00130                                 int sig_flags)
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 }
00147 
00148 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
00149                                 int signum,
00150                                 const ACE_Sig_Set &sig_mask,
00151                                 int sig_flags)
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 }
00166 
00167 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals,
00168                                 ACE_SignalHandler sig_handler,
00169                                 const ACE_Sig_Set &sig_mask,
00170                                 int sig_flags)
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 }
00192 
00193 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals,
00194                                 ACE_SignalHandler sig_handler,
00195                                 sigset_t *sig_mask,
00196                                 int sig_flags)
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 }
00220 
00221 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:18:42 2010 for ACE by  doxygen 1.4.7