Detailed summary of the kill command, except that there are a lot of kill -9
1. The general practice is to terminate the process
To run the program for some time in the process to terminate the program operation, you can use the kill command and the corresponding number for pid process, this method is particularly useful for running in the background:
ps -a
list all processes:
PID TTY TIME CMD
2946 pts/20 00:13:11 python
3523 pts/27 00:00:00 ps
Or use the pipeline to get the corresponding number of the application process:
ps | grep python
2946 pts/20 00:13:55 python
Then you can use this program to shut down the kill:
kill -9 2946
However, kill -9 command in addition, there are many uses:
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Details of sigspec of 2.kill
In the terminal input kill -l
you will see the addition -9 outside there are many other signals:
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
9 wherein the signal is an immediate end to the process of treatment can not be blocked, but the security signal the end of the process can be used 15
, this signal can be blocked process.
More detailed Linux standard signals can here be found.
Common signal the earliest definitions:
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 键盘quit信号
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 后端进程信号
ref:
https://linode.com/docs/tools-reference/tools/use-killall-and-kill-to-stop-processes-on-linux/
https://www.zhihu.com/question/23747655
https://www.geeksforgeeks.org/kill-command-in-linux-with-examples/
https://www.linux.com/learn/intro-to-linux/2017/5/how-kill-process-command-line
https://stackoverflow.com/questions/1624691/linux-kill-background-task/1624730
https://blog.csdn.net/king16304/article/details/52211206
https://blog.csdn.net/Shawei_/article/details/81288938