The difference between kill and kill-9

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.