18

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

eFrane
  • 325

4 Answers4

17

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

sean
  • 186
3

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.

Hack Saw
  • 231
2

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.

Matteo
  • 8,097
  • 3
  • 47
  • 58
1

You can attach to the parent process using lldb -p <parent pid> and then call expr (int)::waitpid(<child pid>, NULL, 0)

This will reap the exit status of the child zombie in the parent, and thus remove the zombie process from the process table.

horseyguy
  • 269