Signal.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Signal.inl,v 4.8 2006/06/19 12:51:17 schmidt Exp
00004 
00005 #include "ace/OS_NS_signal.h"
00006 
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008 
00009 ACE_INLINE
00010 ACE_Sig_Set::ACE_Sig_Set (sigset_t *ss)
00011   // : sigset_ ()
00012 {
00013   ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set");
00014 
00015   if (ss == 0)
00016     ACE_OS::sigfillset (&this->sigset_);
00017   else
00018     // Structure assignment.
00019     this->sigset_ = *ss;
00020 }
00021 
00022 ACE_INLINE
00023 ACE_Sig_Set::ACE_Sig_Set (int fill)
00024   // : sigset_ ()
00025 {
00026   ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set");
00027 
00028   if (fill)
00029     ACE_OS::sigfillset (&this->sigset_);
00030   else
00031     ACE_OS::sigemptyset (&this->sigset_);
00032 }
00033 
00034 ACE_INLINE
00035 ACE_Sig_Set::ACE_Sig_Set (ACE_Sig_Set *ss)
00036   // : sigset_ ()
00037 {
00038   ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set");
00039 
00040   if (ss == 0)
00041     ACE_OS::sigfillset (&this->sigset_);
00042   else
00043     this->sigset_ = ss->sigset_;
00044 }
00045 
00046 ACE_INLINE int
00047 ACE_Sig_Set::empty_set (void)
00048 {
00049   ACE_TRACE ("ACE_Sig_Set::empty_set");
00050   return ACE_OS::sigemptyset (&this->sigset_);
00051 }
00052 
00053 ACE_INLINE int
00054 ACE_Sig_Set::fill_set (void)
00055 {
00056   ACE_TRACE ("ACE_Sig_Set::fill_set");
00057   return ACE_OS::sigfillset (&this->sigset_);
00058 }
00059 
00060 ACE_INLINE int
00061 ACE_Sig_Set::sig_add (int signo)
00062 {
00063   ACE_TRACE ("ACE_Sig_Set::sig_add");
00064   return ACE_OS::sigaddset (&this->sigset_, signo);
00065 }
00066 
00067 ACE_INLINE int
00068 ACE_Sig_Set::sig_del (int signo)
00069 {
00070   ACE_TRACE ("ACE_Sig_Set::sig_del");
00071   return ACE_OS::sigdelset (&this->sigset_, signo);
00072 }
00073 
00074 ACE_INLINE int
00075 ACE_Sig_Set::is_member (int signo) const
00076 {
00077   ACE_TRACE ("ACE_Sig_Set::is_member");
00078   return ACE_OS::sigismember (const_cast<sigset_t *> (&this->sigset_), signo);
00079 }
00080 
00081 ACE_INLINE
00082 ACE_Sig_Set::operator sigset_t *(void)
00083 {
00084   ACE_TRACE ("ACE_Sig_Set::operator sigset_t *");
00085   return &this->sigset_;
00086 }
00087 
00088 ACE_INLINE sigset_t
00089 ACE_Sig_Set::sigset (void) const
00090 {
00091   ACE_TRACE ("ACE_Sig_Set::sigset");
00092   return this->sigset_;
00093 }
00094 
00095 ACE_INLINE int
00096 ACE_Sig_Action::flags (void)
00097 {
00098   ACE_TRACE ("ACE_Sig_Action::flags");
00099   return this->sa_.sa_flags;
00100 }
00101 
00102 ACE_INLINE void
00103 ACE_Sig_Action::flags (int flags)
00104 {
00105   ACE_TRACE ("ACE_Sig_Action::flags");
00106   this->sa_.sa_flags = flags;
00107 }
00108 
00109 ACE_INLINE sigset_t *
00110 ACE_Sig_Action::mask (void)
00111 {
00112   ACE_TRACE ("ACE_Sig_Action::mask");
00113   return &this->sa_.sa_mask;
00114 }
00115 
00116 ACE_INLINE void
00117 ACE_Sig_Action::mask (sigset_t *ss)
00118 {
00119   ACE_TRACE ("ACE_Sig_Action::mask");
00120   if (ss != 0)
00121     this->sa_.sa_mask = *ss; // Structure assignment
00122 }
00123 
00124 ACE_INLINE void
00125 ACE_Sig_Action::mask (ACE_Sig_Set &ss)
00126 {
00127   ACE_TRACE ("ACE_Sig_Action::mask");
00128   this->sa_.sa_mask = ss.sigset (); // Structure assignment
00129 }
00130 
00131 ACE_INLINE ACE_SignalHandler
00132 ACE_Sig_Action::handler (void)
00133 {
00134   ACE_TRACE ("ACE_Sig_Action::handler");
00135   return ACE_SignalHandler (this->sa_.sa_handler);
00136 }
00137 
00138 ACE_INLINE void
00139 ACE_Sig_Action::handler (ACE_SignalHandler handler)
00140 {
00141   ACE_TRACE ("ACE_Sig_Action::handler");
00142 #if !defined(ACE_HAS_TANDEM_SIGNALS)
00143   this->sa_.sa_handler = ACE_SignalHandlerV (handler);
00144 #else
00145   this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (handler);
00146 #endif /* !ACE_HAS_TANDEM_SIGNALS */
00147 }
00148 
00149 #if 0
00150 ACE_INLINE ACE_SignalHandler
00151 ACE_Sig_Action::sigaction (void)
00152 {
00153   ACE_TRACE ("ACE_Sig_Action::sigaction");
00154   return ACE_SignalHandler (this->sa_.sa_sigaction);
00155 }
00156 
00157 ACE_INLINE void
00158 ACE_Sig_Action::sigaction (ACE_SignalHandler handler)
00159 {
00160   ACE_TRACE ("ACE_Sig_Action::sigaction");
00161   this->sa_.sa_sigaction = (void (*)()) ACE_SignalHandlerV (handler);
00162 }
00163 #endif /* 0 */
00164 
00165 ACE_INLINE void
00166 ACE_Sig_Action::set (struct sigaction *sa)
00167 {
00168   ACE_TRACE ("ACE_Sig_Action::set");
00169   this->sa_ = *sa; // Structure assignment.
00170 }
00171 
00172 ACE_INLINE struct sigaction *
00173 ACE_Sig_Action::get (void)
00174 {
00175   ACE_TRACE ("ACE_Sig_Action::get");
00176   return &this->sa_;
00177 }
00178 
00179 ACE_INLINE
00180 ACE_Sig_Action::operator struct sigaction * ()
00181 {
00182   ACE_TRACE ("ACE_Sig_Action::operator struct sigaction *");
00183   return &this->sa_;
00184 }
00185 
00186 ACE_INLINE
00187 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Action &s)
00188   // : sa_ ()
00189 {
00190   ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
00191   *this = s; // structure copy.
00192 }
00193 
00194 ACE_INLINE int
00195 ACE_Sig_Action::register_action (int signum, ACE_Sig_Action *oaction)
00196 {
00197   ACE_TRACE ("ACE_Sig_Action::register_action");
00198   struct sigaction *sa = oaction == 0 ? 0 : oaction->get ();
00199 
00200   return ACE_OS::sigaction (signum, &this->sa_, sa);
00201 }
00202 
00203 ACE_INLINE int
00204 ACE_Sig_Action::retrieve_action (int signum)
00205 {
00206   ACE_TRACE ("ACE_Sig_Action::retrieve_action");
00207   return ACE_OS::sigaction (signum, 0, &this->sa_);
00208 }
00209 
00210 ACE_INLINE int
00211 ACE_Sig_Action::restore_action (int signum, ACE_Sig_Action &oaction)
00212 {
00213   ACE_TRACE ("ACE_Sig_Action::restore_action");
00214   this->sa_ = *oaction.get (); // Structure assignment
00215   return ACE_OS::sigaction (signum, &this->sa_, 0);
00216 }
00217 
00218 // Block out the signal MASK until the destructor is called.
00219 
00220 ACE_INLINE
00221 ACE_Sig_Guard::ACE_Sig_Guard (ACE_Sig_Set *mask,
00222                               bool condition)
00223   : omask_ ()
00224   , condition_ (condition)
00225 {
00226   //ACE_TRACE ("ACE_Sig_Guard::ACE_Sig_Guard");
00227   if (!this->condition_)
00228     return;
00229 
00230 #if defined (ACE_LACKS_UNIX_SIGNALS)
00231   ACE_UNUSED_ARG (mask);
00232 #else
00233   // If MASK is 0 then block all signals!
00234   if (mask == 0)
00235     {
00236 #  if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
00237       ACE_OS::sigprocmask (SIG_BLOCK,
00238                            ACE_OS_Object_Manager::default_mask (),
00239                            (sigset_t *) this->omask_);
00240 #  else
00241       ACE_OS::thr_sigsetmask (SIG_BLOCK,
00242                               ACE_OS_Object_Manager::default_mask (),
00243                               (sigset_t *) this->omask_);
00244 #  endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
00245     }
00246   else
00247 #  if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
00248     ACE_OS::sigprocmask (SIG_BLOCK,
00249                          (sigset_t *) *mask,
00250                          (sigset_t *)
00251                          this->omask_);
00252 #  else
00253     ACE_OS::thr_sigsetmask (SIG_BLOCK,
00254                             (sigset_t *) *mask,
00255                             (sigset_t *)
00256                             this->omask_);
00257 #  endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
00258 #endif /* ACE_LACKS_UNIX_SIGNALS */
00259 }
00260 
00261 ACE_INLINE
00262 ACE_Sig_Handler::ACE_Sig_Handler (void)
00263 {
00264 }
00265 
00266 ACE_INLINE int
00267 ACE_Sig_Handler::in_range (int signum)
00268 {
00269   ACE_TRACE ("ACE_Sig_Handler::in_range");
00270   return signum > 0 && signum < ACE_NSIG;
00271 }
00272 
00273 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:42:03 2006 for ACE by doxygen 1.3.6