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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitykill -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
.
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.kill
command. Love it!kill -KILL
or something?