On Sunday 25 November 2012 06:14, in comp.unix.programmer,
grahn...@snipabacken.se wrote:
> On Sun, 2012-11-25,
alex.v...@gmail.com wrote:
>> Linux 2.6.32-279.5.2.el6.x86_64
>> HP-UX B.11.23 U ia64
>>
>> System call kill(pis, 0) returns 0 (SUCCESS) for both alive and
>> zombie processes. Is there any system call to detect zombie process?
>
> There surely is, since top(1) can tell you if a process is a zombie or
> not. But what problem are you trying to solve? Something tells me
> there may be a better way.
>
> Two observations:
> 1 - AFAIK, all processes pass the zombie state as they die;
> it's not an abnormal state
True, but (as I understand it) incomplete.
All terminating processes must have their termination state collected,
either by their parent process, or (if the parent process has already
terminated) by init. There can be a detectable time between process
termination and process status collection in which the terminated process
will show as "zombie". However, under normal circumstances, this wait time
is minimal to none.
Init reaps orphaned deceased processes quite frequently, so /those/
processes don't often show up in a process listing as "zombie".
OTOH, a parented deceased process must have it's status reaped by the
parent, and should the parent /not/ collect the status in a timely manner,
then the deceased process will persistantly show as "zombie".
So, the processes that show up in the process list as "zombie" are most
often the ones where the still-living parent hasn't collected the status in
a timely manner.
> 2 - you can see if a process is a zombie, but you cannot tell if its
> parent is going to reap it a millisecond from now, on Thursday,
> or never.
True, but you can make an educated guess that might be useful.
Zombie processes with a PPID of 0 will be collected quickly (assuming that
init isn't stuck)
Zombie processes with a PPID != 0 will be collected when the parent gets
around to it.
You can pretty much discount the PPID == 0 zombies, unless you suspect a
systemic init failure.
Just my opinion.
--
Lew Pitcher
"In Skills, We Trust"