8

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?

2
  • You mention Ruby here, and I am curious what the pieces are that you are dealing with. I was using Webrick and had a similar experience, I started using Rack::Server.new and the processes were handled correctly, and would thereafter respond to control-c.
    – vgoff
    Dec 15, 2012 at 1:01
  • vgoff, I will have to collect more information on the process. Let me get back to you on that.
    – cat pants
    Dec 16, 2012 at 1:32

3 Answers 3

15

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.)

4
  • 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
    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. 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
    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). May 11, 2020 at 14:12
8

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.

2
  • Wow, it helped!
    – R Kiselev
    Jan 23, 2018 at 11:27
  • don't work for me, I mistakenly typed cat /**/* as root. And I can never kill it again
    – Y00
    Dec 18, 2020 at 17:56
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.