23,115
社区成员
发帖
与我相关
我的任务
分享
static void signal_handler(int signum)
{
switch (signum)
{
case SIGINT:
printf("signum=SIGINT");
break;
case SIGPIPE:
printf("signum=SIGPIPE"); //无法捕获SIGPIPE
break;
}
}
static void setup_signal_handlers()
{
struct sigaction act;
act.sa_handler = signal_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(SIGINT, &act, NULL);
sigaction(SIGPIPE, &act, NULL);
}