贝贝花花包包店,精品555皮具,钱夹,皮夹

字体:  

关于c++npv1多进程例子中的一点疑问

jerry0715 发表于: 2008-1-31 14:21 来源: ACE 开发者

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);
  }
感觉挺奇怪的。

最新回复

jerry0715 at 2008-2-01 22:47:25
在群里面向大家请教了下,大致明白是怎么回事呢,SIGTERM是信号,对应的是对信号的处理函数,为空操作,至于为什么这写,我还真不知道,自己帮顶一下