Gilles Quénot Asked: 2023-04-22 09:44:35 +0800 CST2023-04-22 09:44:35 +0800 CST 2023-04-22 09:44:35 +0800 CST Como rastrear todo o sinal em 'trap'? 772 Posso testar atalhos de teclado e alguns killcomandos com um script e saber qual sinal é capturado trap? shell 1 respostas Voted Best Answer Gilles Quénot 2023-04-22T09:44:35+08:002023-04-22T09:44:35+08:00 Com este script, você pode testar todos os sinais: #!/bin/sh # Know which signal is caught # man 7 signal trap "echo 'SIGHUP 1 Term Hangup (disconnection) or control process termination.'" 1 trap "echo 'SIGINT 2 Term Interrupt from keyboard.'" 2 trap "echo 'SIGQUIT 3 Core Quit request from keyboard.'" 3 trap "echo 'SIGILL 4 Core Illegal instruction.'" 4 trap "echo 'signal 5 not referenced'" 5 trap "echo 'SIGABRT 6 Core Abort signal from abort(3).'" 6 trap "echo 'signal 7 not referenced'" 7 trap "echo 'SIGFPE 8 Core Floating point arithmetic error.'" 8 trap "echo 'signal 10 not referenced'" 10 trap "echo 'SIGSEGV 11 Core Invalid memory reference.'" 11 trap "echo 'signal 12 not referenced'" 12 trap "echo 'SIGPIPE 13 Term Write on a pipe with no reader.'" 13 trap "echo 'SIGALRM 14 Term Alarm clock signal (used by alarm(2)).'" 14 trap "echo 'SIGTERM 15 Term Termination signal.'" 15 trap "echo 'SIGUSR1 30,10,16 Term User-defined signal 1.'" 30 10 16 trap "echo 'SIGUSR2 31,12,17 Term User-defined signal 2.'" 31 12 17 trap "echo 'SIGCHLD 20,17,18 Ign Child stopped or terminated.'" 20 17 18 trap "echo 'SIGCONT 19,18,25 Cont Continue if stopped.'" 19 18 25 trap "echo 'SIGTSTP 18,20,24 Stop Stop signal generated from keyboard.'" 18 20 24 trap "echo 'SIGTTIN 21,21,26 Stop Background process attempting to read from tty.'" 21 21 26 trap "echo 'SIGTTOU 22,22,27 Stop Background process attempting to write to tty.'" 22 22 27 trap "echo 'SIGWINCH 28,28,20 Ign Window resize signal (4.3 BSD, Sun).'" 28 20 read _ Os sinais SIGKILLe SIGSTOPnão podem ser capturados, bloqueados ou ignorados. ( 9, 19). Veja o sinal do homem 7 E http://mywiki.wooledge.org/SignalTrap Para evitar copiar/colar: wget -O signal-finder.sh https://gist.githubusercontent.com/sputnick-dev/7260ac0aa46f067f469ee8184b69acb3/raw/4286bcda6d3353aad7584ab320048af4d8bfa197/gistfile1.txt chmod +x signal-finder.sh ./signal-finder.sh
Com este script, você pode testar todos os sinais:
Os sinais
SIGKILL
eSIGSTOP
não podem ser capturados, bloqueados ou ignorados. (9
,19
).Veja o sinal do homem 7
E http://mywiki.wooledge.org/SignalTrap
Para evitar copiar/colar: