Sometimes we can't kill a process using kill, but we can use kill-9, why?
First look at the kill function, the man manual for Kill is described as follows:
Kill (1) Linux User ' s Manual Kill (1) NAME kill-send a signal to a processsynopsis KILL [-signal |-S sign AL] pid ... Kill [-L |-V,--version] kill-l [signal]description the default signal for kill is term . Use-l or-l to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Alternate signals is specified in three ways: -9 -sigkill -kill. Negative PID values May is used to choose whole process groups; See the Pgid column in PS command out‐ put. A PID of-1 is special; It indicates all processes except the kill process itself and init.
In the name section: Kill is the role of sending a signal to the process (and not killing the process ha). What signal to send is determined by the parameters followed.
So why do we have to kill the process a lot of the time? See section Desdcription: Kill the default parameter is term. That is, if you do not specify a specific signal as a parameter, the kill term PID is used by default. So the kill PID can kill a process.
So the question comes, why is it that sometimes kills can't kill the process, and kill-9 can?
In the description of the signal in Apue, most of the signals can be captured. And the term signal is in this majority, some processes may capture the terms signal for special purposes, causing you to use the kill PID can not kill the process. In addition, "apue" also stressed that there are two of signals can not be captured, SIGKILL and Sigstop
Note that the both signals SIGKILL and SIGSTOP can ' t be caught.
Yes, kill-9 is sending a sigkill signal to the process.
Kill's Man Handbook:
Signals the signals listed below May is available for use with kill. When known constant, numbers and default behav‐ ior is shown. Name Num Action Description 0 0 N/ A exit code indicates if a signal may be sent Alrm Exit HUP 1 exit INT 2 exit KILL 9 exit Cannot be blocked PIPE to exit POLL exit PROF exit term Exit USR1 exit USR2 exit vtalrm exit Stkflt exit might not be Implemented PWR ignore might exit on some systems ... ......
The difference between kill and kill-9