kill is invoked without any parameter, it sends the signal number 15 (
SIGTERM). This signal can be ignored by the process. This signal notifies the process to clean his things up and then end correctly by himself. That’s the nice way.
You can also “send” the signal number 9 (
SIGKILL) that cannot be ignored by the process. The process will even not recognize it, because the kernel ends the process, not the process itself.That’s the evil way.
kill -9 <pid> always works. That’s a misbelief. There are situations where even
kill -9 does not kill the process. For example when a process has the state
D(uninterruptable sleep). A process comes into this state everytime it waits for I/O (normally not very long). So, if a process waits for I/O (on a defect harddisk for example) and it is not programmed properly (with a timeout), then you simply cannot kill the process. No matter what you do. You just can try to make the file accessible that the process continues.