Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Sig_Adapter.cpp
blob53754975bf7929bb73e614e93822ef607292d67a
1 #include "ace/Sig_Adapter.h"
3 ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Action &sa, int sigkey)
4 : sigkey_ (sigkey),
5 type_ (SIG_ACTION),
6 sa_ (sa),
7 sig_func_ (nullptr)
11 ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Event_Handler *eh, int sigkey)
12 : sigkey_ (sigkey),
13 type_ (ACE_HANDLER),
14 eh_ (eh),
15 sig_func_ (nullptr)
19 ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Handler_Ex sig_func, int sigkey)
20 : sigkey_ (sigkey),
21 type_ (C_FUNCTION),
22 sig_func_ (sig_func)
26 ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Adapter)
28 int
29 ACE_Sig_Adapter::sigkey () const
31 ACE_TRACE ("ACE_Sig_Adapter::sigkey");
32 return this->sigkey_;
35 int
36 ACE_Sig_Adapter::handle_signal (int signum, siginfo_t *siginfo, ucontext_t *ucontext)
38 ACE_TRACE ("ACE_Sig_Adapter::handle_signal");
40 switch (this->type_)
42 case SIG_ACTION:
44 // We have to dispatch a handler that was registered by a
45 // third-party library.
46 ACE_Sig_Action old_disp;
48 // Make sure this handler executes in the context it was
49 // expecting...
50 this->sa_.register_action (signum, &old_disp);
52 ACE_SignalHandler sig_handler = this->sa_.handler ();
53 ACE_Sig_Handler_Ex sig_func = reinterpret_cast<ACE_Sig_Handler_Ex> (reinterpret_cast<void*> (sig_handler));
55 (*sig_func) (signum, siginfo, ucontext);
56 // Restore the original disposition.
57 old_disp.register_action (signum);
58 break;
60 case ACE_HANDLER:
61 this->eh_->handle_signal (signum, siginfo, ucontext);
62 break;
63 case C_FUNCTION:
64 (*this->sig_func_) (signum, siginfo, ucontext);
65 break;
67 return 0;