|
namespace {
extern "C" void sigterm_handler (int /* signum */) { /* No-op. */ }
}
// Register to receive the <SIGTERM> signal.
ACE_Sig_Action sa ((ACE_SignalHandler)sigterm_handler,
SIGTERM);
上面代码在c++NPV1的第八章例子中出现,例子是为了说明
Process_Per_Connection_Logging_Server 的情况
但是上面代码在其他地方调用并未体现出作用,请知道的人解释下,
另外fork方法执行的部分
Logging_Process *logger =
new Logging_Process (prog_name_, logging_peer);
ACE_Process_Options options;
pid_t pid;
pid = ACE_Process_Manager::instance ()->spawn (logger,
options);
// If we came back with pid 0 from the spawn(), this is a
// POSIX fork system - we are in the child process. Handle the
// logging records, then exit.
if (pid == 0) {
acceptor().close ();
handle_data (&logging_peer);
delete logger;
ACE_OS::exit (0);
}
logging_peer.close ();
if (pid == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn()"), -1);
// See if there are any child processes that have
// exited - reap their status and clean up handles held
// open while the child executed.
ACE_Process_Manager::instance ()->wait (0,
ACE_Time_Value::zero);
return 0;
}
是这一部分代码段吗:
if (pid == 0) {
acceptor().close ();
handle_data (&logging_peer);
delete logger;
ACE_OS::exit (0);
}
感觉挺奇怪的。 |
|