Is there a difference between
kill -9 212121
The Ubuntu man page for
Here's what another man page says.
Therefore, using the
kill -9 Meaning: The process will be killed by the kernel; this signal cannot be ignored. 9 means KILL signal that is not catchable or ignorable
Uses: SIGKILL singal
Kill Meaning: The kill command without any signal passes the signal 15, which terminates the process the normal way.
Uses: SIGTERM signal, which can be handled by programmers
Of course we can only kill processes we own, whereas root can kill all processes. See Wikipedia for a nice summary of computing signals.
All three commands below are therefore identical:
The difference between
Note that all of the following are synonymous:
It's worth pointing out that in the world of signal handling, SIGKILL is one of the few unique ones that is handled by the operating system not the program. When you run
After SIGKILL is sent, the program will immediately be stopped. If any kernel calls are running (e.g. File IO) on the program's behalf, those calls may or may not continue until they finish, depending on the call, but the program itself will not run any more. Note that traced tasks or tasks running under a debugger may behave differently here.
The other signal that can't be blocked is SIGSTOP which has a similar effect, but instead freezes the program; you can send SIGCONT later on to resume it. This behavior is completely controlled by the OS, and the program does not get any prior notification.
All the other signals are sent to the program; it can handle them however it chooses, or if it ignores the signal then a default behavior is followed.
Here are a few useful signals that you may find yourself sending to a process:
While all of these signals happen "naturally" in their own setting, you can use the signal to fake a condition to achieve the desired result.
For example, if you want to terminate someone's SSH session you can simply kill the process, but by doing so you'll prevent it from updating its HISTORY file, which may be important for security reasons. But instead if you send it SIGHUP, then the process will assume the connection has died and will perform its standard cleanup.