Unix Bash – Difference Between kill and kill -9

bashkillmanpagesunix

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?

Best Answer

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
Related Question