Linux – Is a persistent zombie process sign of a bug

linuxprocess

(OS: Debian variant.)

Having a process with zombie-status. The PPid belonged to a gvim process.
The contents of /proc/[pid]/wchan is do_exit,
/comm is sh and /cmdline is empty, /status is shown below.

Could this be a bug in gvim? From the Wikipedia entry on Zombie process I read that a program can voluntarily reject to call wait but this was for a
gvim session that had been idle for quite some time. I closed the gvim process – but the zombie still lurks around. Could this indicate a OS bug?

Again from Wikipedia:

If the parent program is no longer running, zombie processes typically indicate a bug in the operating system.

And how often does init reap forsaken processes? It has been at least 60
minutes since gvim's demise but it still there.

On the other hand could it be sh and not gvim?

The /status file states SigQ of zero.

$ less /proc/30339/status
Name     : sh
State    : Z (zombie)
Tgid     : 30339
Pid      : 30339
PPid     : 29673
TracerPid:     0
Uid      :  1000    1000    1000    1000
Gid      :  1000    1000    1000    1000
FDSize   :     0
Groups   :     4 7 20 24 27 29 30 46 107 124 127 1000 
Threads  :     1
SigQ     : 0/30658
SigPnd   : 0000000000000000
ShdPnd   : 0000000000000000
SigBlk   : 0000000000000000
SigIgn   : 0000000000003001
SigCgt   : 0000000000010002
CapInh   : 0000000000000000
CapPrm   : 0000000000000000
CapEff   : 0000000000000000
CapBnd   : ffffffffffffffff
Cpus_allowed     :   3
Cpus_allowed_list:   0-1
Mems_allowed     :   1
Mems_allowed_list:   0
voluntary_ctxt_switches   :   2
nonvoluntary_ctxt_switches:   3

Not that it destroys my beauty sleep, but wondering …

Best Answer

Seeing zombies tends to indicate a bug in the process that spawned them: that process is supposed to reap the zombies (by calling wait) or explicitly ignore SIGCLD (or set the SA_NOCLDWAIT flag).

However this is a minor bug. Zombie processes only consume an entry in the process table, which is a negligible amount of resources. The problem only becomes significant if a process leaves thousands of zombies behind.

You have not killed the parent process of the zombie: otherwise the zombie would have gone away. Process 29673 (the zombie's parent) is still alive and kicking (but not waiting). Either this is not Gvim but some subprocess of it, or you've closed a Gvim window but the program is still running. Run ps l 29673 to see what this process is.

Related Question