sleep()函数会被SIGALRM中断。
如下屏蔽后就好了
// block SIGALRM temporarily
sigemptyset (&sa_mask);
sigaddset (&sa_mask, SIGALRM);
pthread_sigmask (SIG_BLOCK, &sa_mask, NULL);
printf("before sleep\n");
sleep(20);
printf("after sleep\n");
// unblock SIGALRM
pthread_sigmask (SIG_UNBLOCK, &sa_mask, NULL);
阅读(674) | 评论(0) | 转发(0) |