大理石墓安装:操作系统实验 信号操作函数 siginttest.c
来源:百度文库 编辑:偶看新闻 时间:2024/10/05 15:00:51
/**siginttest.c**/
#include
#include
#include
#include
/* 自定义gigint 处理函数,如果按Ctrl+c键,则会打印提示,而不是默认的退出*/
void my_func(int sigo_num){
printf("if you want to quit ,please try 'ctrl+\\'.\n");
}
int main()
{
sigset_t set;
struct sigaction action1,action2;
/* 初始化信号集为空*/
if(sigemptyset(&set)<0)
{
perror("sigemptyset");
exit(1);
}
/* 将相应的信号加入信号集*/
if(sigaddset(&set,SIGQUIT)<0){
perror("sigaddset SIGQUIT");
exit(1);
}
/*将相应的信号加入信号集*/
if(sigaddset(&set,SIGINT)<0){
perror("sigaddset SIGINT");
exit(1);
}
/*设置信号屏蔽字*/
if(sigprocmask(SIG_BLOCK,&set,NULL)<0){
perror("sigprocmask SIG_BLOCK");
exit(1);
}else{
printf("blocked,and sleep for 5s...\n");
sleep(5);
}
if(sigprocmask(SIG_UNBLOCK,&set,NULL)<0){
perror("sigprocmask SIG_UNBLOCK");
exit(1);
}else{
printf("unblock\n");
/* 此处可以添加函数功能模块 process()*/
sleep(2);
printf("if you want to quit this program,please try ...\n");
}
while(1){
if(sigismember(&set,SIGINT)){
sigemptyset(&action1.sa_mask);
action1.sa_handler=my_func;
sigaction(SIGINT,&action1,NULL);
}else
if(sigismember(&set,SIGQUIT)){
sigemptyset(&action2.sa_mask);
action2.sa_handler=SIG_DFL;
sigaction(SIGTERM,&action2,NULL);
}
}
return 0;
}
实验操作
操作系统上机实验
总线信号及其操作?
实验操作题
填写实验操作
实验操作的问题
VLOODUP函数操作
如何操作dos操作系统?
求音频信号放大电路实验电路图
[急。]实验操作安全规划。
[急。]实验操作安全规则。
什么是复解析信号,复解析函数?
关于我的操作操作系统
求操作系统文件系统实验报告源程序?
步步高 k028 性能、操作、信号到底如何?
初中化学实验中的基本操作和注意事项
求教:化学实验操作有哪些?
力学实验机的操作原理?
下列实验操作正确的是()
下列实验操作正确的是()
关于寄生虫实验操作知识的网站
实验操作考试标语\口号
分子生物学实验操作中的“孵育”是什么意思?
关于永动机的实验(易操作的)