# Zombie Process



## mmy (Oct 26, 2009)

Hello
I have 2 zombie process in my freeBSD 7.2

```
top
last pid: 43687;  load averages:  0.00,  0.00,  0.00 13+13:01:23  09:04:54
29 processes:  1 running, 26 sleeping, 2 zombie
```
Use this command to find PIDs :

```
ps aux | grep -w Z
root 35229  0.0  0.0     0     0  ??  Z    Sun08AM   0:00.01 <defunct>
root 50619  0.0  0.0     0     0  ??  Z    11:11AM   0:00.00 <defunct>
```
after that , go to killing zombies :

```
kill -9 35229
kill -9 50619
```
But nothing ! I cant kill zombies .

Now 2 questions :
1)why zombie process in freBSD ?
2)how to kill zombies ?


----------



## aragon (Oct 26, 2009)

Zombies can not be killed.  Remember, zombies are already dead. 

All they do is consume a PID.

http://en.wikipedia.org/wiki/Zombie_process


----------



## mmy (Oct 26, 2009)

So , i cant remove zombies ?


----------



## nocturnal (Oct 26, 2009)

you could reboot the system, that would get rid of it for sure. 

i know that sounds like a stupid suggestion but i've been in a few situations where critical servers have had zombie processes, some even more important like actual running processes becomming zombies and refusing to release some lock. in those cases a reboot is more immediately required than in your case. 

it happens and in those cases you must reboot the system, if it's real bad it might even hang at rebooting the system when it's trying to kill all running PIDs. 

but you have like 65500 PIDs or something like that, as long as it is defunct it won't bother you. just feel lucky it's a regular harmless zombie.


----------



## SirDice (Oct 26, 2009)

Use `# kill -KILL <pid>` or try `# pkill -KILL -f defunct`.


----------



## mmy (Oct 26, 2009)

Don't work !
Nothing :
kill -KILL <pid> or pkill -KILL -f defunct
Zombies stand .

```
ps aux | grep -w Z
root 35229  0.0  0.0     0     0  ??  Z    Sun08AM   0:00.01 <defunct>
root 50619  0.0  0.0     0     0  ??  Z    Sun11AM   0:00.00 <defunct>
```


----------



## tbyte (Oct 26, 2009)

You should restart the process that creates them. Find the parent pid and restart the proccess (demon probably of some kind).


----------



## DutchDaemon (Oct 26, 2009)

Look in the process list for the parent pid (PPID) with [cmd=]ps ajx | grep -w Z[/cmd] (3rd column). 

If it is '1' the parent has already gone (init has adopted the zombie); nothing to be done there (I don't think signalling init will work). 

Any other id should point to the parent, which you can try to send a SIGCHLD signal(3) to to reap its defunct children.


----------



## tbyte (Oct 26, 2009)

DutchDaemon said:
			
		

> If it is '1' the parent has already gone (init has adopted the zombie); nothing to be done there (I don't think signalling init will work).
> 
> Any other id should point to the parent, which you can try to send a SIGCHLD signal(3) to to reap its defunct children.



As far as I know , init don't just 'adopts' zombies and do nothing, it 'reaps' them (so they die). So if the parent process has died the zombies die to.

SIGCHLD is pretty optimistic, it may sometimes work. But it's probably something very wrong with the parent process.


----------



## mmy (Oct 26, 2009)

```
ps ajx | grep -w Z
root 35229 35227 35229 35229    0 Z     ??    0:00.01 <defunct>
root 50619 35227 50619 50619    0 Z     ??    0:00.00 <defunct>
root 19612 19589 19611 19564    2 R+    p0    0:00.00 grep -w Z
```
I think need rebooting .


----------



## tbyte (Oct 26, 2009)

Noo don't reboot just restart whatever is pid 35227.

ps xalp 35227


----------



## DutchDaemon (Oct 26, 2009)

tbyte said:
			
		

> As far as I know , init don't just 'adopts' zombies and do nothing, it 'reaps' them (so they die). So if the parent process has died the zombies die to.



Yep, got confused with _orphaned_ processes there, which are 'functional children' whose parent has died and which are adopted by init.


----------



## fronclynne (Oct 27, 2009)

Frequently when starting xorg with startx you will get one or two zombie /bin/sh, which seem to be the leftovers from putting ampersands after things that don't run continually after your start xorg, like xset or xsetroot.

Anyway, they're harmless, though you can eventually get rid of them if you dig around enough.


----------



## mmy (Oct 27, 2009)

tbyte said:
			
		

> Noo don't reboot just restart whatever is pid 35227.
> ps xalp 35227



Tanks tbyte .
Zombies go away .


----------



## kenorb (Oct 25, 2010)

```
> ps wuax | grep defunct
kenorb     59680  0.0  0.0     0     0  ??  Z    10:47AM   0:02.49 <defunct>
kenorb     59684  0.0  0.0     0     0  ??  Z    10:47AM   0:00.83 <defunct>
kenorb      7390  0.0  0.0     0     0   0  Z    Fri09AM   0:10.44 <defunct>
kenorb     16225  0.0  0.0     0     0   0  Z    Fri09AM   0:00.46 <defunct>
kenorb     10114  0.0  0.0     0     0   2  Z    Fri03PM   0:52.26 <defunct>
kenorb     13675  0.0  0.0     0     0   2  Z    Fri03PM   0:32.94 <defunct>
kenorb     36032  0.0  0.0     0     0   2  Z    Fri12PM   0:07.15 <defunct>
kenorb     39820  0.0  0.0     0     0   2  Z    Fri03PM   0:03.08 <defunct>
kenorb     61226  0.0  0.0     0     0   2  Z    Fri03PM   0:04.93 <defunct>
kenorb     82860  0.0  0.0     0     0   2  Z    Fri02PM   6:08.18 <defunct>
kenorb     83528  0.0  0.0     0     0   2  Z    Fri03PM   3:31.92 <defunct>
kenorb     83648  0.0  0.0     0     0   2  Z    Fri03PM   0:37.18 <defunct>
kenorb     86192  0.0  0.0     0     0   2  Z    Fri03PM   0:01.13 <defunct>
kenorb     50855  0.0  0.0     0     0   3  Z    Fri12PM   0:18.38 <defunct>
```

It's normal in FreeBSD to have everyday 14 zombies?


----------



## SirDice (Oct 25, 2010)

kenorb said:
			
		

> It's normal in FreeBSD to have everyday 14 zombies?


Nope.


```
dice@molly:~>uptime
12:18PM  up 11 days, 15:48, 3 users, load averages: 0.00, 0.02, 0.00
dice@molly:~>ps -aux | grep defunct
dice       50493  0.0  0.0   552   300   3  DL+  12:18PM   0:00.00 grep defunct
```


```
dice@williscorto:~>uptime
12:19PM  up 47 days, 15:15, 7 users, load averages: 0.00, 0.00, 0.04
dice@williscorto:~>ps -aux | grep defuct
dice       67805  0.0  0.0  3496  1028   5  S+   12:19PM   0:00.00 grep defuct
```


----------

