I imagine that kill -9 still just sends a signal to a process. If the process is not behaving well, I would imagine that kill -9 would have no effect. Indeed, today for the first time I saw kill -9 have no effect when sent to a stuck ruby process. So here is my question: Is there some harsher way to kill a process?
3 Answers
You have to reboot the machine. If kill -9 doesn't kill a process, that means it is stuck in the kernel. Unless you can figure out what it's stuck on and unstick it, there's nothing you can do. The reason it's stuck is that it is waiting for something and the logic necessary to cleanly stop waiting simply doesn't exist.
(The above assumes the process has already been reparented to init. Otherwise, its parent may be keeping it around. You may have to kill its parent.)
-
1+1 like the answer. What I have found is it's often stuck on waiting for a parent that's already dead. A zombie won't take up memory, but it can fill up the process table if you have 1000s and occupy ports it's bound to.aseq– aseq2012-12-15 00:16:21 +00:00Commented Dec 15, 2012 at 0:16
-
A zombie process shouldn't be able to occupy ports. When the process terminates, all its file descriptors should be closed even before it's reaped. At least, that's what I'd always assumed.David Schwartz– David Schwartz2012-12-15 00:27:49 +00:00Commented Dec 15, 2012 at 0:27
-
You may be right. I can't verify for certain, but at least it was (were) process(es) that couldn't be killed with kill -9 occupying a port.aseq– aseq2012-12-15 02:21:01 +00:00Commented Dec 15, 2012 at 2:21
-
FWIW, I had a stuck process that even had an open windows that wouldn’t close (frozen). SIGPWR didn’t help either, I had to reboot (Ubuntu 20.04 beta).Torsten Bronger– Torsten Bronger2020-05-11 14:12:07 +00:00Commented May 11, 2020 at 14:12
Every time I have a job that is stuck and signals 9 or 15 won't kill it, I send it signal 30 (SIGPWR) and almost every single time it will clear it out. I can't recall when sending the power outage signal didn't work.
-
Wow, it helped!Roman Kiselev– Roman Kiselev2018-01-23 11:27:57 +00:00Commented Jan 23, 2018 at 11:27
-
don't work for me, I mistakenly typed cat /**/* as root. And I can never kill it againY00– Y002020-12-18 17:56:39 +00:00Commented Dec 18, 2020 at 17:56
Yes there is, a reboot...
Normally though being unable to kill -9 a process is not such a problem since these processes are not doing much to hog your system, they're probably just zombies. The only time it necessitated me to reboot in order to get rid of it is when it was "occupying" a tcp port I needed to use.
Rack::Server.newand the processes were handled correctly, and would thereafter respond tocontrol-c.