Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / Service_Configurator / IPC-tests / server / server_test.cpp
blob2a10db41423f1f61411bbe7cd4123114e015fbc5
1 // The main test driver for the dynamically configured server.
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Service_Config.h"
5 #include "ace/Reactor.h"
6 #include "ace/Log_Msg.h"
7 #include "ace/Signal.h"
8 #include "ace/Sig_Adapter.h"
10 int
11 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
13 if (ACE_Service_Config::open (argc,
14 argv,
15 ACE_DEFAULT_LOGGER_KEY,
16 0) == -1)
17 ACE_ERROR_RETURN ((LM_ERROR,
18 ACE_TEXT ("%p\n"),
19 ACE_TEXT ("ACE_Service_Config::open")),
20 -1);
22 // Create an adapter to end the event loop.
23 ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop);
25 ACE_Sig_Set sig_set;
26 sig_set.sig_add (SIGINT);
27 sig_set.sig_add (SIGQUIT);
29 // Register ourselves to receive signals so we can shut down
30 // gracefully.
31 if (ACE_Reactor::instance ()->register_handler (sig_set,
32 &sa) == -1)
33 ACE_ERROR_RETURN ((LM_ERROR,
34 ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")),
35 -1);
37 // This makes the README demo even easier (for sighup).
38 ACE_DEBUG ((LM_DEBUG,
39 ACE_TEXT ("pid = %d\n"),
40 ACE_OS::getpid ()));
42 // Run forever, performing the configured services until we are shut
43 // down by a SIGINT/SIGQUIT signal.
45 // We use this version of the event loop so that reconfigurations
46 // are triggered properly.
47 ACE_Reactor::run_event_loop ();
49 return 0;