typedef void (*sigaction_func)(int, siginfo_t*, void*); static void signal_handler(int signo, siginfo_t* siginfo, void* context) { …… } static sigaction_func signal_install_handler(void) { struct sigaction act, oact; sigemptyset(&act.sa_mask); act.sa_sigaction = signal_handler; act.sa_flags = 0; act.sa_flags |= SA_SIGINFO; // 使用3个参数的信号处理函数 act.sa_flags |= SA_RESTART; // 信号返回时,重新调研系统函数。 if (sigaction(RES_SIGNAL, &act, &oact) < 0) { errmsg("not able to set up signal action handler"); } /* Return previously installed handler */ return oact.sa_sigaction; }