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