스크립트를 사용하여 키보드 단축키와 일부 kill
명령을 테스트하고 어떤 신호가 포착되는지 알 수 있습니까 trap
?
답변1
이 스크립트를 사용하면 모든 신호를 테스트할 수 있습니다.
#!/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 _
이러한 신호는 포착, 차단 또는 무시될 SIGKILL
수 없습니다 . SIGSTOP
( 9
, 19
).
바라보다맨 7 시그널
그리고http://mywiki.wooledge.org/SignalTrap
복사/붙여넣기를 방지하려면:
wget -O signal-finder.sh https://gist.githubusercontent.com/sputnick-dev/7260ac0aa46f067f469ee8184b69acb3/raw/4286bcda6d3353aad7584ab320048af4d8bfa197/gistfile1.txt
chmod +x signal-finder.sh
./signal-finder.sh