Fixed typos
[ACE_TAO.git] / ACE / ace / Signal.cpp
blobb04b80042966584e98f4db60306cfb03e9778fdb
1 #include "ace/Signal.h"
2 // #include "ace/Log_Category.h"
4 #if defined (ACE_HAS_ALLOC_HOOKS)
5 # include "ace/Malloc_Base.h"
6 #endif /* ACE_HAS_ALLOC_HOOKS */
8 #if !defined (__ACE_INLINE__)
9 #include "ace/Signal.inl"
10 #endif /* __ACE_INLINE__ */
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Action)
19 void
20 ACE_Sig_Action::dump (void) const
22 #if defined (ACE_HAS_DUMP)
23 ACE_TRACE ("ACE_Sig_Action::dump");
24 #endif /* ACE_HAS_DUMP */
27 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Set)
29 ACE_Sig_Set::~ACE_Sig_Set (void)
31 ACE_TRACE ("ACE_Sig_Set::~ACE_Sig_Set");
32 ACE_OS::sigemptyset (&this->sigset_);
35 ACE_Sig_Action::~ACE_Sig_Action (void)
37 ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action");
40 // Restore the signal mask.
42 ACE_Sig_Guard::~ACE_Sig_Guard (void)
44 //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard");
45 if (!this->condition_)
46 return;
48 #if !defined (ACE_LACKS_UNIX_SIGNALS)
49 #if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
50 ACE_OS::sigprocmask (SIG_SETMASK,
51 (sigset_t *) this->omask_,
52 0);
53 #else
54 ACE_OS::thr_sigsetmask (SIG_SETMASK,
55 (sigset_t *) this->omask_,
56 0);
57 #endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
58 #endif /* !ACE_LACKS_UNIX_SIGNALS */
61 void
62 ACE_Sig_Set::dump (void) const
64 #if defined (ACE_HAS_DUMP)
65 ACE_TRACE ("ACE_Sig_Set::dump");
66 #endif /* ACE_HAS_DUMP */
69 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Guard)
71 void
72 ACE_Sig_Guard::dump (void) const
74 #if defined (ACE_HAS_DUMP)
75 ACE_TRACE ("ACE_Sig_Guard::dump");
76 #endif /* ACE_HAS_DUMP */
79 ACE_Sig_Action::ACE_Sig_Action (void)
81 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
82 this->sa_.sa_flags = 0;
84 // Since Service_Config::signal_handler_ is static and has an
85 // ACE_Sig_Action instance, Win32 will get errno set unless this is
86 // commented out.
87 #if !defined (ACE_WIN32)
88 ACE_OS::sigemptyset (&this->sa_.sa_mask);
89 #endif /* ACE_WIN32 */
90 this->sa_.sa_handler = 0;
93 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
94 sigset_t *sig_mask,
95 int sig_flags)
97 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
98 this->sa_.sa_flags = sig_flags;
100 if (sig_mask == 0)
101 ACE_OS::sigemptyset (&this->sa_.sa_mask);
102 else
103 this->sa_.sa_mask = *sig_mask; // Structure assignment...
105 #if !defined(ACE_HAS_TANDEM_SIGNALS)
106 this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
107 #else
108 this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
109 #endif /* !ACE_HAS_TANDEM_SIGNALS */
112 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
113 const ACE_Sig_Set &sig_mask,
114 int sig_flags)
116 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
117 this->sa_.sa_flags = sig_flags;
119 // Structure assignment...
120 this->sa_.sa_mask = sig_mask.sigset ();
122 #if !defined(ACE_HAS_TANDEM_SIGNALS)
123 this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
124 #else
125 this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
126 #endif /* !ACE_HAS_TANDEM_SIGNALS */
129 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
130 int signum,
131 sigset_t *sig_mask,
132 int sig_flags)
134 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
135 this->sa_.sa_flags = sig_flags;
137 if (sig_mask == 0)
138 ACE_OS::sigemptyset (&this->sa_.sa_mask);
139 else
140 this->sa_.sa_mask = *sig_mask; // Structure assignment...
142 #if !defined(ACE_HAS_TANDEM_SIGNALS)
143 this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
144 #else
145 this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
146 #endif /* !ACE_HAS_TANDEM_SIGNALS */
147 ACE_OS::sigaction (signum, &this->sa_, 0);
150 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler,
151 int signum,
152 const ACE_Sig_Set &sig_mask,
153 int sig_flags)
155 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
156 this->sa_.sa_flags = sig_flags;
158 // Structure assignment...
159 this->sa_.sa_mask = sig_mask.sigset ();
161 #if !defined(ACE_HAS_TANDEM_SIGNALS)
162 this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
163 #else
164 this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
165 #endif /* !ACE_HAS_TANDEM_SIGNALS */
166 ACE_OS::sigaction (signum, &this->sa_, 0);
169 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals,
170 ACE_SignalHandler sig_handler,
171 const ACE_Sig_Set &sig_mask,
172 int sig_flags)
174 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
175 this->sa_.sa_flags = sig_flags;
177 // Structure assignment...
178 this->sa_.sa_mask = sig_mask.sigset ();
180 #if !defined(ACE_HAS_TANDEM_SIGNALS)
181 this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
182 #else
183 this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
184 #endif /* !ACE_HAS_TANDEM_SIGNALS */
186 #if (ACE_NSIG > 0)
187 for (int s = 1; s < ACE_NSIG; s++)
188 if ((signals.is_member (s)) == 1)
189 ACE_OS::sigaction (s, &this->sa_, 0);
190 #else /* ACE_NSIG <= 0 */
191 ACE_UNUSED_ARG (signals);
192 #endif /* ACE_NSIG <= 0 */
195 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals,
196 ACE_SignalHandler sig_handler,
197 sigset_t *sig_mask,
198 int sig_flags)
200 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
201 this->sa_.sa_flags = sig_flags;
203 if (sig_mask == 0)
204 ACE_OS::sigemptyset (&this->sa_.sa_mask);
205 else
206 this->sa_.sa_mask = *sig_mask; // Structure assignment...
208 #if !defined(ACE_HAS_TANDEM_SIGNALS)
209 this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler);
210 #else
211 this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler);
212 #endif /* !ACE_HAS_TANDEM_SIGNALS */
214 #if (ACE_NSIG > 0)
215 for (int s = 1; s < ACE_NSIG; s++)
216 if ((signals.is_member (s)) == 1)
217 ACE_OS::sigaction (s, &this->sa_, 0);
218 #else /* ACE_NSIG <= 0 */
219 ACE_UNUSED_ARG (signals);
220 #endif /* ACE_NSIG <= 0 */
223 ACE_END_VERSIONED_NAMESPACE_DECL