9

I cannot figure out what the difference is between

kill -9 <pid>

and

kill -INT <pid>

can anyone explain it to me like I am 3 years old?

5
  • 3
    kill -INT $pid is like sticking a rod through pid to see what happens. Maybe it'll die, maybe it won't. kill -9 $pid will kill pid with fire and it absolutely will not stop until pid is dead. Oct 20, 2017 at 21:19
  • lol that will def help a 3 year old understand :) Oct 20, 2017 at 21:47
  • @PSkocik, Hilarious. Like a fairy tale fable about the kill command. Love it!
    – RobertL
    Oct 23, 2017 at 20:50
  • Can -9 also be represent by a "string", such as kill -KILL or something? Oct 23, 2017 at 21:33
  • 1
    @AlexanderMills yes, see "Advanced Concepts" in the answer below.
    – RobertL
    Oct 26, 2017 at 3:38

1 Answer 1

15

kill -INT $pid sends the "interrupt" signal to the process with process ID pid. However, the process may decide to ignore the signal, or catch the signal and do something before exiting and/or ignore it.

kill -9 $pid sends the "kill" signal which cannot be caught or ignored. The process will be forcibly shut down with no notification to the process, and no chance to do any cleanup what so ever. kill -9 $pid should almost never be recommended or used, though sometimes it's necessary.

Advanced Concepts

kill -INT $pid is the same as kill -2 $pid.
kill -9 $pid is the same as kill -KILL $pid

There are many versions of the kill command. Most shells (ksh, bash, dash, etc) have built-in kill commands, and there's also one in /bin/kill. They are all slightly different but most of them support the above examples.

Most kill commands have a -l or -L option to list the signals:

$ /bin/kill -L
 1 HUP      2 INT      3 QUIT     4 ILL      5 TRAP     6 ABRT     7 BUS
 8 FPE      9 KILL    10 USR1    11 SEGV    12 USR2    13 PIPE    14 ALRM
15 TERM    16 STKFLT  17 CHLD    18 CONT    19 STOP    20 TSTP    21 TTIN
22 TTOU    23 URG     24 XCPU    25 XFSZ    26 VTALRM  27 PROF    28 WINCH
29 POLL    30 PWR     31 SYS     
$

A good place to read about signals is the "signal" man page in section 7 of the manual: man 7 signal.

1
  • 5
    kill -9 may also be written kill -KILL.
    – Kusalananda
    Oct 20, 2017 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .