Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I kill a zombie process whose parent is PID = 0?

Often, when running LLDB on OSX, the debugger will sporadically crash (this just seems to be the nature of LLDB). When this happens, I get a zombie process (the one I was debugging) that looks really strange. It has parent PID = 0:

My process is called: worker

Here is the output of ps aux | grep worker

root            22785   0.0  0.0        0      0   ??  Z     3:48pm   0:00.00 (worker)

As you can see, the process has a PID, but it has no parent PID. This does nothing

sudo kill -9 <pid>

In fact, nothing short of a restart seems to get rid of it. How can I kill a process like that? I need the process to die, because it holds on to ports that I need.

like image 908
Thomas Kejser Avatar asked Nov 29 '25 14:11

Thomas Kejser


2 Answers

Zombie is the name given to processes which already died. So they do not run any longer and they do not consume system resources any longer. They are only listed in the process table which could not be properly updated at the time the zombie process finished running. This is also the reason why they are not assigned to any meaningful parent.

Therefore you can not kill a zombie for a second time (as their name already implies, in contrary to what happens in medium-level horror movies :-)). In most operating systems it is enough to wait for some time for the zombie processes to disappear from the list of processes. Or you have to do a reboot if you can not live with this.

Rest assured, zombies will do no harm to you.

like image 87
Artur Opalinski Avatar answered Dec 01 '25 06:12

Artur Opalinski


The situation is that it is not possible, as a user, to clean up a zombie process; the kernel will handle it when it's ready, if possible.

As detailed in Mac OS X and iOS Internals,

it is a perfectly normal state and every process usually spends an infinitesimal amount of time, just before it can rest in peace....Parents who outlive, yet forsake their children and move on to other things, will damn the children to be stuck in the quasi-dead state of a zombie. Zombies are, for all intents and purposes, quite dead.

Since the debugger acts as the parent to its target process, which holds a network port and the debugger has crashed, it leaves the target process in the zombie state. The problem here is the crash of the debugger.

like image 36
TheDarkKnight Avatar answered Dec 01 '25 05:12

TheDarkKnight