4
This commit is contained in:
@@ -50,10 +50,10 @@ typedef void (*sighandler_t) (int sig) ;
|
||||
|
||||
void Signal(int sig, sighandler_t handler){
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = sigchld_handler;
|
||||
sa.sa_handler = handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART; // 确保被信号中断的系统调用自动重启
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
sigaction(sig, &sa, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
port = atoi(argv[1]);
|
||||
|
||||
//设置SIGHLD的信号处理函数,用于收割结束的子进程
|
||||
Signal(SIGCHLD, sigchld_handler);
|
||||
Signal(SIGPIPE, SIG_IGN);
|
||||
listen_sock = open_listen_sock(port);
|
||||
|
||||
for (hit=1; ; hit++) { //hit为第几次请求,或第几次http事务
|
||||
|
||||
Reference in New Issue
Block a user