1000 Ways to Die (`kill`)
kill
, and its sister killall
, are likely familiar to you already. They are simple tools to send signals to a process. Most commonly they are used to end processes with the TERM
signal.
Signals we care about:
TERM
: Cleanly exit a process, like a CTL+C.HUP
: 'Hang up,' many services such as databases use this signal as a notice to restart without terminating. Eg, for a configuration change.KILL
: Harshly exit a process, without allowing graceful shutdown.STOP
: Pause a process, like a CTL+Z.CONT
: Resume a process.
kill
requires a PID (such as from ps
), while killall
supports process names.
Terminating a process:
Sending a specific signal:
Pausing a process for several seconds:
Exercises
Try sending
STOP
to a runningapache2
server. Do requests still work? Now sendCONT
and test again, does it work again?Open a psql shell (
sudo -u postgres psql
), try sending anHUP
topostgres
using another shell, does yourpsql
shell stop working? What about when you sendKILL
?
Last updated