Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!bu-cs!bucsb.bu.edu!madd From: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Newsgroups: comp.unix.wizards Subject: Re: Zombies ??? Message-ID: <648@bucsb.bu.edu.UUCP> Date: Tue, 9-Dec-86 18:24:05 EST Article-I.D.: bucsb.648 Posted: Tue Dec 9 18:24:05 1986 Date-Received: Wed, 10-Dec-86 04:45:34 EST References: <1327@brl-adm.ARPA> Reply-To: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Organization: ODO (Organization for the Disorganization of Organization) Lines: 41 Keywords: pipes Mood: Wet and bedraggled. In article <1327@brl-adm.ARPA> larry@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 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@bucsb.bu.edu CSNET: madd%bucsb@bu-cs | BITNET: cscc71c@bostonu -------------------------------+---+------------------------------------ "Oh beer, oh beer." -- Me | [=(BEER) <- Bud the Beer (cheers!)