标签:control illegal mina break comm tin keyboard value ali
1、信号帮助:方法一:#man 7 signal
方法二:#kill -l
方法三:#trap -l
2、常用信号列表
Signal Value Action Comment ────────────────────────────────────────────────────────────────────── SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term Broken pipe: write to pipe with no readers SIGALRM 14 Term Timer signal from alarm(2) SIGTERM 15 Term Termination signal SIGUSR1 30,10,16 Term User-defined signal 1 SIGUSR2 31,12,17 Term User-defined signal 2 SIGCHLD 20,17,18 Ign Child stopped or terminated SIGCONT 19,18,25 Cont Continue if stopped SIGSTOP 17,19,23 Stop Stop process SIGTSTP 18,20,24 Stop Stop typed at terminal SIGTTIN 21,21,26 Stop Terminal input for background process SIGTTOU 22,22,27 Stop Terminal output for background process |
3、trap:捕捉信号,
它不能捕捉9号信号(SIGKILL)和15号信号(SIGTERM),一般常用的捕捉信号是HUP和INT信号。
可以自定义捕捉信号后的处理方法
4、trap命令用法:
格式:trap 'command ' signal //command为捕捉信号后要执行的命令或脚本或函数,多个命令之间用分号(;)隔开;signal为要捕捉的信号
示例1:
[root@localhost sh]# cat tr.sh
#!/bin/bash
trap 'echo "quit";exit' INT //一般把trap写在最上面,多个command之间用分号(;)隔开,
for i in {1..10};do
ping -W 1 -c 1 192.168.0.$i
done
[root@localhost sh]#
示例二:
标签:control illegal mina break comm tin keyboard value ali
原文地址:http://blog.51cto.com/10631377/2063226