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
)
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_
)
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_
,
54 ACE_OS::thr_sigsetmask (SIG_SETMASK
,
55 (sigset_t
*) this->omask_
,
57 #endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
58 #endif /* !ACE_LACKS_UNIX_SIGNALS */
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
)
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
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
,
97 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
98 this->sa_
.sa_flags
= sig_flags
;
101 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
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
);
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
,
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
);
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
,
134 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
135 this->sa_
.sa_flags
= sig_flags
;
138 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
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
);
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
,
152 const ACE_Sig_Set
&sig_mask
,
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
);
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
,
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
);
183 this->sa_
.sa_handler
= (void (*)()) ACE_SignalHandlerV (sig_handler
);
184 #endif /* !ACE_HAS_TANDEM_SIGNALS */
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
,
200 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
201 this->sa_
.sa_flags
= sig_flags
;
204 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
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
);
211 this->sa_
.sa_handler
= (void (*)()) ACE_SignalHandlerV (sig_handler
);
212 #endif /* !ACE_HAS_TANDEM_SIGNALS */
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