进程间通信______信号集
来源:互联网 发布:剑三抓马坐标数据下载 编辑:程序博客网 时间:2024/04/28 18:53
#include <sys/types.h>#include <unistd.h>#include <signal.h>#include <stdio.h>#include <stdlib.h>void my_func(int signum){printf("If you want to quit,please try SIGQUIT\n");}int main(){sigset_t set,pendset;struct sigaction action1,action2;if(sigemptyset(&set)<0) //初始化信号集为空perror("sigemptyset");if(sigaddset(&set,SIGQUIT)<0)//添加信号perror("sigaddset");if(sigaddset(&set,SIGINT)<0) //添加信号perror("sigaddset");if(sigprocmask(SIG_BLOCK,&set,NULL)<0) //加入信号到进程屏蔽perror("sigprocmask");else{printf("blocked\n");sleep(3);}if(sigprocmask(SIG_UNBLOCK,&set,NULL)<0)//从进程屏蔽中将信号删除perror("sigprocmask");elseprintf("unblock\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);}}}
0 0
- 进程间通信______信号集
- 进程间通信______信号
- 进程间通信______管道
- 进程间通信______有名管道(FIFO)
- 进程间通信______共享内存
- 进程间通信______消息队列
- 进程间通信-信号
- 进程间通信--信号
- 进程间通信--信号
- 进程间通信-信号
- 进程间通信---信号
- 【进程间通信】信号
- 进程间通信----信号
- 【进程间通信】信号
- 信号通信(进程间通信)
- 进程间通信之信号
- 进程间通信:信号机制
- 3、进程间通信-信号
- UVA 712 S-Trees
- Codeforces 50C Happy Farm 5 凸包
- 批处理中如何判断参数中含有某些字符串?
- Oracle内存管理(之五)
- 不自动添加换行符的puts()
- 进程间通信______信号集
- WebLogic之domain域安装
- poj-1751 Highways 最小生成树
- UVa 11584 - Partitioning by Palindromes(简单DP)
- Codeforces 451 D. Count Good Substrings
- python读取文件
- windows线程池的使用
- 在Eclipse中安装StatET插件
- WPF:DataGrid分页实现