唐山兴邦管道:信号操作函数
来源:百度文库 编辑:偶看新闻 时间:2024/05/03 17:46:17
#include
#include
#include
#include
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");
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;}
运行结果如下图所示:
#include
#include
#include
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");
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函数操作
什么是复解析信号,复解析函数?
步步高 k028 性能、操作、信号到底如何?
关于api函数的文件操作
函数在Excel中如何操作? 视频教程
文件系统操作涉及到函数及数据结构
显示器突然失去信号,任何操作无响应
C语言文件位置指针的操作函数问题
用Excel2003做二次函数,具体怎么操作啊
求c++的文件操作函数以及使用方法
C语言能直接对API函数进行操作吗
file_get_contents怎么用,算是文件操作函数伐
WriteFile 利用vb api函数 写文件操作?
谁有可以上网操作函数图象的网站?
电磁信号可以看成时间的函数,它可以是____的或____的
知道滤波器信号函数 如何用matlab求滤波器的weight
函数~~~~~~~~~~~~
函数......
函数!!!!!!!!!!!
函数!!!!!!!!!!!
函数......
如何用matlab编程使其输出e的-t次方乘以阶跃函数u(t)的信号波形
不我想用C语言操作word文件 不知道有谁有相关的接口函数