[root@sre ~]# kill -l
 1) SIGHUP   2) SIGINT   3) SIGQUIT  4) SIGILL   5) SIGTRAP
 6) SIGABRT  7) SIGBUS   8) SIGFPE   9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG  24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF 28) SIGWINCH    29) SIGIO   30) SIGPWR
31) SIGSYS  34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX    

Linux支持的信号列表如下。很多信号是与机器的体系结构相关的

信号值 默认处理动作 发出信号的原因
SIGHUP 1 A 终端挂起或者控制进程终止
SIGINT 2 A 键盘中断(如break键被按下)
SIGQUIT 3 C 键盘的退出键被按下
SIGILL 4 C 非法指令
SIGABRT 6 C 由abort(3)发出的退出指令
SIGFPE 8 C 浮点异常
SIGKILL 9 AEF Kill信号
SIGSEGV 11 C 无效的内存引用
SIGPIPE 13 A 管道破裂: 写一个没有读端口的管道
SIGALRM 14 A 由alarm(2)发出的信号
SIGTERM 15 A 终止信号
SIGUSR1 30,10,16 A 用户自定义信号1
SIGUSR2 31,12,17 A 用户自定义信号2
SIGCHLD 20,17,18 B 子进程结束信号
SIGCONT 19,18,25 进程继续(曾被停止的进程)
SIGSTOP 17,19,23 DEF 终止进程
SIGTSTP 18,20,24 D 控制终端(tty)上按下停止键
SIGTTIN 21,21,26 D 后台进程企图从控制终端读
SIGTTOU 22,22,27 D 后台进程企图从控制终端写

处理动作一项中的字母含义如下:

A 缺省的动作是终止进程
B 缺省的动作是忽略此信号,将该信号丢弃,不做处理
C 缺省的动作是终止进程并进行内核映像转储(dump core),内核映像转储是指将进程数据在内存的映像和进程在内核结构中的部分内容以一定格式转储到文件系统,并且进程退出执行,这样做的好处是为程序员提供了方便,使得他们可以得到进程当时执行时的数据值,允许他们确定转储的原因,并且可以调试他们的程序。
D 缺省的动作是停止进程,进入停止状况以后还能重新进行下去,一般是在调试的过程中(例如ptrace系统调用)
E 信号不能被捕获
F 信号不能被忽略

各种信号及其用途

Signal Description Signal number on Linux x86[1] 
SIGABRT Process aborted 6 
SIGALRM Signal raised by alarm 14 
SIGBUS Bus error: "access to undefined portion of memory object" 7 
SIGCHLD Child process terminated, stopped (or continued*) 17 
SIGCONT Continue if stopped 18 
SIGFPE Floating point exception: "erroneous arithmetic operation" 8 
SIGHUP Hangup 1 
SIGILL Illegal instruction 4 
SIGINT Interrupt 2 
SIGKILL Kill (terminate immediately) 9 
SIGPIPE Write to pipe with no one reading 13 
SIGQUIT Quit and dump core 3 
SIGSEGV Segmentation violation 11 
SIGSTOP Stop executing temporarily 19 
SIGTERM Termination (request to terminate) 15 
SIGTSTP Terminal stop signal 20 
SIGTTIN Background process attempting to read from tty ("in") 21 
SIGTTOU Background process attempting to write to tty ("out") 22 
SIGUSR1 User-defined 1 10 
SIGUSR2 User-defined 2 12 
SIGPOLL Pollable event 29 
SIGPROF Profiling timer expired 27 
SIGSYS Bad syscall 31 
SIGTRAP Trace/breakpoint trap 5 
SIGURG Urgent data available on socket 23 
SIGVTALRM Signal raised by timer counting virtual time: "virtual timer expired" 26 
SIGXCPU CPU time limit exceeded 24 
SIGXFSZ File size limit exceeded 25

kill实际上是用来发送信号量给进程,通过man kill查看信号量列表:

 Name     Num   Action    Description
 0          0   n/a       exit code indicates if a signal may be sent
 ALRM      14   exit
 HUP        1   exit
 INT        2   exit
 KILL       9   exit      cannot be blocked
 PIPE      13   exit
 POLL           exit
 PROF           exit
 TERM      15   exit
 USR1           exit
 USR2           exit
 VTALRM         exit
 STKFLT         exit      might not be implemented
 PWR            ignore    might exit on some systems
 WINCH          ignore
 CHLD           ignore
 URG            ignore
 TSTP           stop      might interact with the shell
 TTIN           stop      might interact with the shell
 TTOU           stop      might interact with the shell
 STOP           stop      cannot be blocked
 CONT           restart   continue if stopped, otherwise ignore
 ABRT       6   core
 FPE        8   core
 ILL        4   core
 QUIT       3   core
 SEGV      11   core
 TRAP       5   core
 SYS            core      might not be implemented
 EMT            core      might not be implemented
 BUS            core      core dump might fail
 XCPU           core      core dump might fail
 XFSZ           core      core dump might fail

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code