What to do if kill -9 doesn't work?

I've got a pesky process (in this case, a stranded process that was supposed to be running in iPhone Simulator (now long quit).

97442 ??         0:00.00 (MyProcess)

I've tried everything I can think of, including

sudo kill -9 97442
sudo kill -HUP 97442

And yet, like the Raven... the process remains.

In this case, it means in order to continue working I have to reboot my machine.


Solution 1:

When a process remains in the process table as this process has, then you need to kill its parent process. First, find the parent process PID:

ps -eo 'pid,ppid,comm' | grep 97442

Then run kill <pid> for whatever the ppid result is. (Give it a chance to die cleanly, first.)

The traditional Unix design keeps process information around for the parents to reap and clean up, in case the parent processes want to run getrusage(2) to find out the resource usage of its children, or wait(2) for their exit status, etc.

When parents don't reap their children, the children remain zombies -- UNTIL the parent process is killed, at which point the kernel will re-parent the children to init(8). init(8) will reap the newly re-parented children.