Introduction: turning the next man and info help manual, which describes the trap commands are in English. See some headaches, find a Chinese version of this explanation, come under the reprint save:
https://blog.csdn.net/carolzhang8406/article/details/46504415/
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ---------------------------------- trap of using
1, run format
Trap command parameters are divided into two parts, the first part is the action upon receipt of a specified signal to be taken, after the name of part of the signal to be processed.
trap command signal
There are three forms corresponding to three different signal response mode.
The first:
trap "commands" signal-list
When the script receives a signal listed in the signal-list list, trap command execution commands double quotes.
The second:
trap signal-list
trap does not specify any command, accept the default operating signals, the default action is to end the process running.
Third:
trap " " signal-list
trap command specifies an empty command string, allowed to ignore the signal, we use is this one.
※ Remember, the script usually interpreted in order from top to bottom, so you must specify the trap command in that part of the code you want to protect before.
Semaphore detailed list can be displayed to trap -l
Because now it was certainly no linux machine at hand, I'll list Come
Name Description Default action
SIGHUP terminate process terminal line hang up
SIGINT terminate process interrupt process
SIGQUIT establish CORE file terminate the process and generates core file
SIGILL Illegal instruction establish CORE file
SIGTRAP establish CORE document tracking trap
CORE file SIGBUS establish bus error
SIGSEGV establish CORE file segments illegal error
SIGFPE establish CORE file floating-point exception
SIGIOT establish CORE perform file I / O trap
SIGKILL Terminate the process to kill the process
SIGPIPE terminate process write data to a process not read the pipeline
To terminate the process when the timer SIGALARM
SIGTERM terminate process software termination signal
SIGSTOP stop process stop signal to the non-terminal
SIGTSTP terminal to stop the process of the stop signal
SIGCONT ignored a stop signal to continue the process
SIGURG ignore the signal I / O emergency signal
May be I / O Descriptor on ignore signals SIGIO
Ignoring SIGCHLD signal notifies the parent process when a child process to stop or quit
SIGTTOU stop the process of background processes write terminal
SIGTTIN stop process background process reads terminal
SIGXGPU termination process CPU time limit timeout
SIGXFSZ termination process file is too long
SIGWINCH ignore signals window size changes
SIGPROF statistical distribution termination process with the timer expires
SIGUSR1 terminate process User defined signal 1
SIGUSR2 terminate the process user-defined signal 2
SIGVTALRM terminate the process to the virtual timer