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 class MySignalHandler
: public ACE_Event_Handler
9 MySignalHandler (int signum
) : signum_(signum
)
12 virtual ~MySignalHandler ()
15 virtual int handle_signal (int signum
, siginfo_t
* = 0, ucontext_t
* = 0)
17 ACE_TRACE ("MySignalHandler::handle_signal");
19 // Make sure the right handler was called back..
20 ACE_ASSERT(signum
== this->signum_
);
22 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%d occurred\n"), signum
));
31 // Listing 1 code/ch11
32 int ACE_TMAIN (int, ACE_TCHAR
*[])
34 MySignalHandler
h1 (SIGUSR1
), h2 (SIGUSR1
);
35 ACE_Sig_Handlers handler
;
36 handler
.register_handler (SIGUSR1
, &h1
);
37 handler
.register_handler (SIGUSR1
, &h2
);
39 ACE_OS::kill (ACE_OS::getpid (), SIGUSR1
);
42 while ((time
= ACE_OS::sleep (time
)) == -1)
47 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p\n"),
48 ACE_TEXT ("sleep")), -1);