1.1. 什么是信号
1.1.1. 信号是内容受限的一种异步通信机制
a. 之所以称之为受限是因为通信内容在OS已经规定,内容简单,单一(signal.h文件中定义好)
b. 信号本质上是int型数字编号(事先定义好的)
1.2. 信号处理
1.2.1. 忽略信号
a. 忽略信号就是不做任何处理,保护默认处理也会忽略(但9号信号是不能被忽略的)
1.2.2. 捕获信号
a. 信号绑定了一个函数,设置捕获函数后就会忽略默认处理,但9号信号是不能被忽略的
1.2.3. 默认处理
a. 当前进程没有明显的管这个信号,默认:忽略或终止进程,比如SIGINT默认终止前台进程
1.3. 信号类型
#define SIGHUP 1 #define SIGINT 2 #define SIGQUIT 3 #define SIGILL 4 #define SIGTRAP 5 #define SIGABRT 6 #define SIGIOT 6 #define SIGBUS 7 #define SIGFPE 8 #define SIGKILL 9 #define SIGUSR1 10 #define SIGSEGV 11 #define SIGUSR2 12 #define SIGPIPE 13 #define SIGALRM 14 #define SIGTERM 15 #define SIGSTKFLT 16 #define SIGCHLD 17 #define SIGCONT 18 #define SIGSTOP 19 #define SIGTSTP 20 #define SIGTTIN 21 #define SIGTTOU 22 #define SIGURG 23 #define SIGXCPU 24 #define SIGXFSZ 25 #define SIGVTALRM 26 #define SIGPROF 27 #define SIGWINCH 28 #define SIGIO 29 #define SIGPOLL SIGIO /* #define SIGLOST 29 */ #define SIGPWR 30 #define SIGSYS 31 #define SIGUNUSED 31