Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS3 / jaws3 / Signal_Task.cpp
blob855d39e4f1b3852617e9ad833d9f12c6067a4565
1 #include "ace/OS_NS_signal.h"
2 #include "ace/OS_NS_Thread.h"
3 #include "ace/Thread.h"
5 #ifndef JAWS_BUILD_DLL
6 #define JAWS_BUILD_DLL
7 #endif
9 #include "jaws3/Signal_Task.h"
10 #include "jaws3/Event_Dispatcher.h"
11 #include "jaws3/THYBRID_Concurrency.h"
12 #include "jaws3/TPOOL_Concurrency.h"
13 #include "jaws3/TPR_Concurrency.h"
16 ACE_THR_FUNC_RETURN
17 JAWS_Signal_Task_function (void *)
19 int done = 0;
21 while (! done)
23 int signo = ACE_OS::sigwait (JAWS_Signal_Task::instance ()->sigset ());
25 switch (signo)
27 case SIGINT:
28 case SIGTERM:
30 JAWS_Concurrency::instance ()->shutdown ();
31 JAWS_Event_Dispatcher::end_event_loop ();
33 done = 1;
35 break;
36 # if !defined (ACE_WIN32)
37 case SIGHUP:
38 // In the future, re-read jaws.conf and svc.conf,
39 // and then reset the JAWS singletons.
40 // For now, just ignore it.
41 break;
43 case SIGPIPE:
44 #endif // !defined (ACE_WIN32)
45 default:
46 break;
51 return 0;
55 JAWS_Signal_Task::JAWS_Signal_Task ()
57 // Set our signal mask.
58 this->sigset_.empty_set ();
60 this->sigset_.sig_add (SIGINT);
61 this->sigset_.sig_add (SIGTERM);
62 this->sigset_.sig_add (SIGPIPE);
64 #if 0
65 this->sigset_.fill_set ();
66 #endif
68 ACE_OS::sigprocmask (SIG_BLOCK, this->sigset_, 0);
70 int result;
71 result = ACE_Thread::spawn ( JAWS_Signal_Task_function
72 , 0
73 , THR_BOUND
75 if (result < 0)
77 ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn"));
78 return;