Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My man page does not document the difference between

kill <pid>

and

kill -9 <pid>

Since these do different things why is the -9 not documented in the kill manpage? I thought maybe it was a shell specific things so I looked in the bash man page too but no luck.

Bonus question: what does the -9 do?

share|improve this question
add comment

3 Answers

up vote 17 down vote accepted

kill just sends a signal to the given process. The -9 tells it which signal to send.

Different numbers correspond to different common signals. SIGINT, for example, is 2, so to send a process the SIGINT signal issue the command

$ kill -2 <pid>

The manpage here specifies:

The default signal for kill is TERM.

The manpage also provides a table of signals you can send. According to this table, TERM is 15, so these are all equivalent:

kill <pid>
kill -15 <pid>
kill -TERM <pid>

Notice 9 is the KILL signal.

   Name   Number  Action
   -----------------------
   ALRM      14   exit
   HUP        1   exit
   INT        2   exit
   KILL       9   exit  this signal may not be blocked
   PIPE      13   exit
   POLL           exit
   PROF           exit
   TERM      15   exit     [Default]
   USR1           exit
   USR2           exit
   VTALRM         exit
   STKFLT         exit  may not be implemented
   PWR            ignore    may exit on some systems
   WINCH          ignore
   CHLD           ignore
   URG            ignore
   TSTP           stop  may interact with the shell
   TTIN           stop  may interact with the shell
   TTOU           stop  may interact with the shell
   STOP           stop  this signal may not be blocked
   CONT           restart   continue if stopped, otherwise ignore
   ABRT       6   core
   FPE        8   core
   ILL        4   core
   QUIT       3   core
   SEGV      11   core
   TRAP       5   core
   SYS            core  may not be implemented
   EMT            core  may not be implemented
   BUS            core  core dump may fail

   XCPU           core  core dump may fail
   XFSZ           core  core dump may fail
share|improve this answer
4  
The default signal(kill <pid>) is TERM. –  heavyd Feb 11 '10 at 13:59
5  
The numbers are usually, but not always, the same on different Unix-based systems. It's better practice to use the signal name. That is, instead of kill -9, use kill -KILL. –  mpez0 Feb 11 '10 at 14:42
4  
I would add that the KILL and STOP signals are so-called non-catchable signals. That means when a TERM signal is sent to a process, it is able to catch it and perform various "shutdown" operations it needs to do. The KILL signal stops the process immediately. –  Neo Feb 11 '10 at 14:53
2  
It's best to use the default signal first and only use -9 if the default doesn't work. The reason for this is that -9 can't be caught so the program doesn't have a chance to do any cleanup. Also, you find the documentation for signals on your system in man 7 signal –  Dennis Williamson Feb 11 '10 at 17:17
add comment

The default signal is TERM which allows the program being killed to catch it and do some cleanup before exiting. A program can ignore it, too, if it's written that way.

Specifying -9 or KILL as the signal does not allow the program to catch it, do any cleanup or ignore it. It should only be used as a last resort.

To see the list of numbers and signal names in Bash, use kill -l (letter ell).

share|improve this answer
add comment

I am using Ubuntu Linux.

Kill commands basically sends signal to process to end it. To simplify complex behavioral expectations of everyday computing kill command has various options along with it.

As explained above with all the kill numbers options corresponding to its definition.

I would like to add few lines to it.

 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    

As you see above these are all kill options you will get if you run Ubuntu Linux.

But certain kill signals are common across all *NIX flavors.

kill -9 is SIGKILL option and kernel can not ignore this signal, meaning it has honor this -9 or SIGKILL option and exit process immediately. Remember this process cannot be handled by application programs.

kill -15 on the other hand will send SIGTERM signal, meaning it will wait for process to cleanly shutdown before exit. This is default signal.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.