Zombies ???

Jim "Jack" Frost madd at bucsb.bu.edu.UUCP
Wed Dec 10 09:24:05 AEST 1986


In article <1327 at brl-adm.ARPA> larry at MITRE.arpa (Larry Henry) writes:
>
>	Does anyone out there have a clear understanding of exactly what
>	situations create zombie processes ??

One of the ways you can do it is not to close pipes when opening them
from within a process with popen().  If you repeatedly open a pipe
using the same variable and either omit the pclose() or use a
fclose(), this should cause zombies.  Killing the parent kills all of
them, BTW.

Example:

-- cut here --
#include <stdio.h>

main()
{ FILE *p,*popen();

  for (;;) {
    if ((p=popen("ps","r"))!=NULL) {
      /* do something with the data */
      fclose(p); /* <- omit this statement for same effect */
    }
    sleep(5);
  }
}
-- cut here --

Anyway, this should cause a new zombie every 5 seconds or so until the
parent is killed.

I'm sure there are others, but this one can be pretty nasty.  I found
it while playing with a daemon I was writing.
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   - Jim Frost * The Madd Hacker -
UUCP:  ..!harvard!bu-cs!bucsb!madd | ARPANET: madd at bucsb.bu.edu
CSNET: madd%bucsb at bu-cs            | BITNET:  cscc71c at bostonu
-------------------------------+---+------------------------------------
"Oh beer, oh beer." -- Me      |      [=(BEER) <- Bud the Beer (cheers!)



More information about the Comp.unix.wizards mailing list