2 #include "ace/OS_NS_signal.h"
3 #include "ace/config-all.h"
5 #include "ace/Object_Manager_Base.h"
6 #include "ace/OS_NS_Thread.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 ACE_Sig_Set::ACE_Sig_Set (sigset_t *ss)
14 ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set");
17 ACE_OS::sigfillset (&this->sigset_);
19 // Structure assignment.
24 ACE_Sig_Set::ACE_Sig_Set (bool fill)
27 ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set");
30 ACE_OS::sigfillset (&this->sigset_);
32 ACE_OS::sigemptyset (&this->sigset_);
36 ACE_Sig_Set::ACE_Sig_Set (ACE_Sig_Set *ss)
39 ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set");
42 ACE_OS::sigfillset (&this->sigset_);
44 this->sigset_ = ss->sigset_;
48 ACE_Sig_Set::empty_set ()
50 ACE_TRACE ("ACE_Sig_Set::empty_set");
51 return ACE_OS::sigemptyset (&this->sigset_);
55 ACE_Sig_Set::fill_set ()
57 ACE_TRACE ("ACE_Sig_Set::fill_set");
58 return ACE_OS::sigfillset (&this->sigset_);
62 ACE_Sig_Set::sig_add (int signo)
64 ACE_TRACE ("ACE_Sig_Set::sig_add");
65 return ACE_OS::sigaddset (&this->sigset_, signo);
69 ACE_Sig_Set::sig_del (int signo)
71 ACE_TRACE ("ACE_Sig_Set::sig_del");
72 return ACE_OS::sigdelset (&this->sigset_, signo);
76 ACE_Sig_Set::is_member (int signo) const
78 ACE_TRACE ("ACE_Sig_Set::is_member");
79 return ACE_OS::sigismember (const_cast<sigset_t *> (&this->sigset_), signo);
83 ACE_Sig_Set::operator sigset_t *()
85 ACE_TRACE ("ACE_Sig_Set::operator sigset_t *");
86 return &this->sigset_;
90 ACE_Sig_Set::sigset () const
92 ACE_TRACE ("ACE_Sig_Set::sigset");
97 ACE_Sig_Action::flags ()
99 ACE_TRACE ("ACE_Sig_Action::flags");
100 return this->sa_.sa_flags;
104 ACE_Sig_Action::flags (int flags)
106 ACE_TRACE ("ACE_Sig_Action::flags");
107 this->sa_.sa_flags = flags;
110 ACE_INLINE sigset_t *
111 ACE_Sig_Action::mask ()
113 ACE_TRACE ("ACE_Sig_Action::mask");
114 return &this->sa_.sa_mask;
118 ACE_Sig_Action::mask (sigset_t *ss)
120 ACE_TRACE ("ACE_Sig_Action::mask");
122 this->sa_.sa_mask = *ss; // Structure assignment
126 ACE_Sig_Action::mask (ACE_Sig_Set &ss)
128 ACE_TRACE ("ACE_Sig_Action::mask");
129 this->sa_.sa_mask = ss.sigset (); // Structure assignment
132 ACE_INLINE ACE_SignalHandler
133 ACE_Sig_Action::handler ()
135 ACE_TRACE ("ACE_Sig_Action::handler");
136 return ACE_SignalHandler (this->sa_.sa_handler);
140 ACE_Sig_Action::handler (ACE_SignalHandler handler)
142 ACE_TRACE ("ACE_Sig_Action::handler");
143 this->sa_.sa_handler = ACE_SignalHandlerV (handler);
147 ACE_Sig_Action::set (struct sigaction *sa)
149 ACE_TRACE ("ACE_Sig_Action::set");
150 this->sa_ = *sa; // Structure assignment.
153 ACE_INLINE struct sigaction *
154 ACE_Sig_Action::get ()
156 ACE_TRACE ("ACE_Sig_Action::get");
161 ACE_Sig_Action::operator struct sigaction * ()
163 ACE_TRACE ("ACE_Sig_Action::operator struct sigaction *");
168 ACE_Sig_Action::register_action (int signum, ACE_Sig_Action *oaction)
170 ACE_TRACE ("ACE_Sig_Action::register_action");
171 struct sigaction *sa = oaction == nullptr ? nullptr : oaction->get ();
173 return ACE_OS::sigaction (signum, &this->sa_, sa);
177 ACE_Sig_Action::retrieve_action (int signum)
179 ACE_TRACE ("ACE_Sig_Action::retrieve_action");
180 return ACE_OS::sigaction (signum, 0, &this->sa_);
184 ACE_Sig_Action::restore_action (int signum, ACE_Sig_Action &oaction)
186 ACE_TRACE ("ACE_Sig_Action::restore_action");
187 this->sa_ = *oaction.get (); // Structure assignment
188 return ACE_OS::sigaction (signum, &this->sa_, 0);
191 // Block out the signal MASK until the destructor is called.
194 ACE_Sig_Guard::ACE_Sig_Guard (ACE_Sig_Set *mask,
197 , condition_ (condition)
199 //ACE_TRACE ("ACE_Sig_Guard::ACE_Sig_Guard");
200 if (!this->condition_)
203 #if defined (ACE_LACKS_UNIX_SIGNALS)
204 ACE_UNUSED_ARG (mask);
206 // If MASK is nullptr then block all signals!
209 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
210 ACE_OS::sigprocmask (SIG_BLOCK,
211 ACE_OS_Object_Manager::default_mask (),
212 (sigset_t *) this->omask_);
214 ACE_OS::thr_sigsetmask (SIG_BLOCK,
215 ACE_OS_Object_Manager::default_mask (),
216 (sigset_t *) this->omask_);
217 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
220 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
221 ACE_OS::sigprocmask (SIG_BLOCK,
226 ACE_OS::thr_sigsetmask (SIG_BLOCK,
230 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
231 #endif /* ACE_LACKS_UNIX_SIGNALS */
234 ACE_END_VERSIONED_NAMESPACE_DECL