Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / APG / Signals / SigGuard.cpp
blobdbecbd10d963bd719e703abad97ce13f53c63a41
1 #include "ace/OS_NS_unistd.h"
2 #include "ace/Log_Msg.h"
3 #include "ace/Signal.h"
4 #include "ace/Sig_Handler.h"
6 // Listing 1
7 class MySignalHandler : public ACE_Event_Handler
9 public:
10 virtual int handle_signal(int signo, siginfo_t * = 0, ucontext_t * = 0)
12 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Signal %d\n"), signo));
13 return 0;
17 int ACE_TMAIN (int, ACE_TCHAR *[])
19 MySignalHandler sighandler;
20 ACE_Sig_Handler sh;
21 sh.register_handler (SIGUSR1, &sighandler);
23 ACE_Sig_Set ss;
24 ss.sig_add (SIGUSR1);
26 ACE_Sig_Guard guard (&ss);
28 ACE_DEBUG ((LM_DEBUG,
29 ACE_TEXT ("Entering critical region\n")));
30 ACE_OS::sleep (10);
31 ACE_DEBUG ((LM_DEBUG,
32 ACE_TEXT ("Leaving critical region\n")));
35 // Do other stuff.
37 return 0;
39 // Listing 1