23,125
社区成员
发帖
与我相关
我的任务
分享
sigset_t newmask, oldmask;
sigemptyset(&newmask);
sigemptyset(&oldmask);
sigaddset(&newmask, SIGINT);
//block SIGINT and save current signal mask
if(sigprocmask(SIG_BLOCK,&newmaks,&oldmask)<0)
err_sys("SIG_BLOCK error");
//critical region of code
//reset signal mask, which unblocks SIGINT
if(sigprocmask(SIG_SETMASK,&oldmask,NULL)<0)
err_sys("SIG_SETMASK error");
//window is open
pause();//wait for signal to occur
//continue processing