复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include <stdio.h> #include <stdlib.h> #include <signal.h> void handler_signal(int signum) { printf("Recive signum : %d.n",signum); return; } int main(int argc, const char *argv[]) { //设置进程对信号的处理方式 //1.忽略SIGINT信号 if(signal(SIGINT,SIG_IGN)== SIG_ERR) { perror("Fail to signal"); exit(EXIT_FAILURE); } //2.捕捉SIGUSR1信号 if(signal(SIGUSR1,handler_signal) == SIG_IGN) { perror("Fail to signal"); exit(EXIT_FAILURE); } //3.默认处理SIGCHLD if(signal(SIGCHLD,SIG_DFL) == SIG_ERR) { perror("Fail to signal"); exit(EXIT_FAILURE); } while(1); exit(EXIT_SUCCESS); }
SIGALRM
复制代码
1
2
3
4
5
6
7
8
9
10
11#include <stdio.h> #include <stdlib.h> #include <signal.h> void hander_signal(int signum) { return; } int main(int argc, const char *argv[]) { //设置进程对SIGALRM信号为捕捉 if(signal(SIGALRM,hander_signal) == SIG_E
最后
以上就是忐忑哈密瓜最近收集整理的关于Signal的全部内容,更多相关Signal内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复