1 #include "ace/OS_NS_unistd.h"
2 #include "ace/OS_NS_stdlib.h"
3 #include "ace/Log_Msg.h"
5 #include "ace/Signal.h"
7 // Forward declaration.
8 static void register_actions ();
10 int ACE_TMAIN (int, ACE_TCHAR
*[])
14 ::register_actions (); // Register actions to happen.
16 // This will be raised immediately.
17 ACE_OS::kill (ACE_OS::getpid(), SIGUSR2
);
19 // This will pend until the first signal is completely
20 // handled and returns, because we masked it out
21 // in the registerAction call.
22 ACE_OS::kill (ACE_OS::getpid (), SIGUSR1
);
24 while (ACE_OS::sleep (100) == -1)
34 #if defined (ACE_HAS_SIG_C_FUNC)
37 // Listing 3 code/ch11
38 static void my_sighandler (int signo
)
40 ACE_TRACE ("::my_sighandler");
42 ACE_OS::kill (ACE_OS::getpid (), SIGUSR1
);
45 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Signal SIGUSR1\n")));
47 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Signal SIGUSR2\n")));
51 #if defined (ACE_HAS_SIG_C_FUNC)
55 // Listing 2 code/ch11
56 static void register_actions ()
58 ACE_TRACE ("::register_actions");
60 ACE_Sig_Action
sa (reinterpret_cast <ACE_SignalHandler
> (my_sighandler
));
62 // Make sure we specify that SIGUSR1 will be masked out
63 // during the signal handler's execution.
68 // Register the same handler function for these
70 sa
.register_action (SIGUSR1
);
71 sa
.register_action (SIGUSR2
);