1 #include "ace/Signal.h"
3 #if defined (ACE_HAS_ALLOC_HOOKS)
4 # include "ace/Malloc_Base.h"
5 #endif /* ACE_HAS_ALLOC_HOOKS */
7 #if !defined (__ACE_INLINE__)
8 #include "ace/Signal.inl"
9 #endif /* __ACE_INLINE__ */
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Action
)
16 ACE_Sig_Action::dump () const
18 #if defined (ACE_HAS_DUMP)
19 ACE_TRACE ("ACE_Sig_Action::dump");
20 #endif /* ACE_HAS_DUMP */
23 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Set
)
25 ACE_Sig_Set::~ACE_Sig_Set ()
27 ACE_TRACE ("ACE_Sig_Set::~ACE_Sig_Set");
28 ACE_OS::sigemptyset (&this->sigset_
);
31 ACE_Sig_Action::~ACE_Sig_Action ()
33 ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action");
36 /// Restore the signal mask.
37 ACE_Sig_Guard::~ACE_Sig_Guard ()
39 //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard");
40 if (!this->condition_
)
43 #if !defined (ACE_LACKS_UNIX_SIGNALS)
44 #if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
45 ACE_OS::sigprocmask (SIG_SETMASK
,
46 (sigset_t
*) this->omask_
,
49 ACE_OS::thr_sigsetmask (SIG_SETMASK
,
50 (sigset_t
*) this->omask_
,
52 #endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
53 #endif /* !ACE_LACKS_UNIX_SIGNALS */
57 ACE_Sig_Set::dump () const
59 #if defined (ACE_HAS_DUMP)
60 ACE_TRACE ("ACE_Sig_Set::dump");
61 #endif /* ACE_HAS_DUMP */
64 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Guard
)
67 ACE_Sig_Guard::dump () const
69 #if defined (ACE_HAS_DUMP)
70 ACE_TRACE ("ACE_Sig_Guard::dump");
71 #endif /* ACE_HAS_DUMP */
74 ACE_Sig_Action::ACE_Sig_Action ()
76 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
77 this->sa_
.sa_flags
= 0;
79 // Since Service_Config::signal_handler_ is static and has an
80 // ACE_Sig_Action instance, Win32 will get errno set unless this is
82 #if !defined (ACE_WIN32)
83 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
84 #endif /* ACE_WIN32 */
85 this->sa_
.sa_handler
= 0;
88 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler
,
92 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
93 this->sa_
.sa_flags
= sig_flags
;
95 if (sig_mask
== nullptr)
96 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
98 this->sa_
.sa_mask
= *sig_mask
; // Structure assignment...
100 this->sa_
.sa_handler
= ACE_SignalHandlerV (sig_handler
);
103 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler
,
104 const ACE_Sig_Set
&sig_mask
,
107 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
108 this->sa_
.sa_flags
= sig_flags
;
110 // Structure assignment...
111 this->sa_
.sa_mask
= sig_mask
.sigset ();
112 this->sa_
.sa_handler
= ACE_SignalHandlerV (sig_handler
);
115 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler
,
120 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
121 this->sa_
.sa_flags
= sig_flags
;
123 if (sig_mask
== nullptr)
124 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
126 this->sa_
.sa_mask
= *sig_mask
; // Structure assignment...
128 this->sa_
.sa_handler
= ACE_SignalHandlerV (sig_handler
);
129 ACE_OS::sigaction (signum
, &this->sa_
, 0);
132 ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler
,
134 const ACE_Sig_Set
&sig_mask
,
137 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
138 this->sa_
.sa_flags
= sig_flags
;
140 // Structure assignment...
141 this->sa_
.sa_mask
= sig_mask
.sigset ();
142 this->sa_
.sa_handler
= ACE_SignalHandlerV (sig_handler
);
143 ACE_OS::sigaction (signum
, &this->sa_
, 0);
146 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set
&signals
,
147 ACE_SignalHandler sig_handler
,
148 const ACE_Sig_Set
&sig_mask
,
151 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
152 this->sa_
.sa_flags
= sig_flags
;
154 // Structure assignment...
155 this->sa_
.sa_mask
= sig_mask
.sigset ();
156 this->sa_
.sa_handler
= ACE_SignalHandlerV (sig_handler
);
159 for (int s
= 1; s
< ACE_NSIG
; s
++)
160 if ((signals
.is_member (s
)) == 1)
161 ACE_OS::sigaction (s
, &this->sa_
, 0);
162 #else /* ACE_NSIG <= 0 */
163 ACE_UNUSED_ARG (signals
);
164 #endif /* ACE_NSIG <= 0 */
167 ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set
&signals
,
168 ACE_SignalHandler sig_handler
,
172 // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action");
173 this->sa_
.sa_flags
= sig_flags
;
176 ACE_OS::sigemptyset (&this->sa_
.sa_mask
);
178 this->sa_
.sa_mask
= *sig_mask
; // Structure assignment...
180 this->sa_
.sa_handler
= ACE_SignalHandlerV (sig_handler
);
183 for (int s
= 1; s
< ACE_NSIG
; s
++)
184 if ((signals
.is_member (s
)) == 1)
185 ACE_OS::sigaction (s
, &this->sa_
, 0);
186 #else /* ACE_NSIG <= 0 */
187 ACE_UNUSED_ARG (signals
);
188 #endif /* ACE_NSIG <= 0 */
191 ACE_END_VERSIONED_NAMESPACE_DECL