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