#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
int temp = 0;
void handler_sigint(int signo)
{
printf("receive signal!\n");
sleep(3);
temp += 2;
printf("the value of temp is: %d!\n",temp);
printf("in handler_sigint,after a sleep!\n");
}
int main()
{
struct sigaction act;
act.sa_handler = handler_sigint;
act.sa_flags = SA_NOMASK;
sigaction(SIGINT, &act, NULL);
while(1)
{
printf("looping now!\n");
sleep(3);
}
return 0;
}
sigaction函数嵌套处理信号简单介绍
最新推荐文章于 2024-12-27 17:51:11 发布