首页 > 其他 > 详细

使用sigaction处理SIGINT时阻塞SIGQUIT

时间:2020-06-06 22:27:04      阅读:75      评论:0      收藏:0      [点我收藏+]
# include <stdio. h>
# include <signal.h>
# define INPUTLEN 100 
void inthandler();
int main() 
{
struct sigaction newhandler; sigset_t blocked; char x[INPUTLEN]; newhandler.sa_handler=inthandler; newhandler.sa_flags=SA_RESETHAND|SA_RESTART; sigemptyset(&blocked); sigaddset(&blocked,SIGQUIT); newhandler.sa_mask=blocked; if( sigaction( SIG1NT, &newhandler, NULL) = = - 1 ) perror("sigaction"); else whileC 1 ) { fgets(x,INLUTLEN,stdin); printf("input:%s",x); }
}
void inthandler( int s) { printf( "Called with signal 屯 d\n飞的 J sleep(s); printf("done handling signal %d\n",s); }

 

使用sigaction处理SIGINT时阻塞SIGQUIT

原文:https://www.cnblogs.com/cs0915/p/13056704.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!