How to kill a zombie process on a mac

28,548

Solution 1

Hack Saw says:

Sadly, it appears that killing of zombies is all about killing the parent, and if the parent is /sbin/launchd, you can kill it only with rebooting.

It would be a Very Bad Idea to kill launchd, but you can tell it to HUP.

Try sudo kill -s HUP 1

That will cause launchd to reinitialize without restarting. This has worked for me in the past (wrt. removing zombie entries).

Solution 2

Sadly, it appears that killing of zombies is all about killing the parent, and if the parent is /sbin/launchd, you can kill it only with rebooting.

I'm getting zombies from using Xcode, and stopping the simulator, and it's handing the zombies to my own personal /sbin/launchd, which didn't go away when I logged out.

ps -xo pid,ppid,stat,command will show you your processes, with their parent ID in the second column.

Solution 3

zombie processes are already dead and cannot be killed. They should be removed from the process table automatically when the parent process dies.

They do not slow down your machine and you can leave them there (they are just entries in the process table).

There is a maximum number of processes (you can check it with sysctl kern.maxproc) and zombie processes will reduce it (as they are counted).

If you reach this limit you will not be able to create new processes and you will be forced to reboot.

Share:
28,548

Related videos on Youtube

eFrane
Author by

eFrane

Updated on September 18, 2022

Comments

  • eFrane
    eFrane almost 2 years

    How to kill a zombie process or find it's parent process on a Mac using the Terminal?

    • soandos
      soandos over 12 years
    • HikeMike
      HikeMike over 12 years
      @soandos Not a duplicate, as that topic isn't about zombies. None of the kill signals work for zombies IIRC. I've had this happen before.
    • eFrane
      eFrane over 12 years
      Usually one can kill zombies if the parent process is known but this requires killing that one too, which is not always a pleasant choice. Therefore I am wondering if there is another solution to this.
  • JRG-Developer
    JRG-Developer over 11 years
    "Should be removed", but they're not always. Xcode is terrible about leaving zombie processes, and they aren't cleaned up even if Xcode dies / is quit / is killed.
  • Matteo
    Matteo over 11 years
    @JRG-Developer I agree but they are not a problem. They do no consume any resource.
  • Matteo
    Matteo over 11 years
    @Adam Yes, you are correct. They do not slow down your computer but they reserve resources. On my Mac (8GB of RAM) the limit is set to 2048. I updated my answer
  • Matteo
    Matteo over 9 years
    Why should they be a problem?
  • George
    George about 9 years
    When an App gets in that state then you can't relaunch it until the old entry is cleared out. It isn't using any resources but the pollution of the table prevents a new instance from launching, therefore you're blocked until you reboot.