Difference between `kill -9 ` and `kill -INT `

killsignals

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?

Best Answer

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.

Related Question