forking and zombies in SYSV.

Thomas Tornblom thomas at uplog.se
Tue Aug 21 00:33:01 AEST 1990


In article <1990Aug20.133107.12516 at lth.se> jh at efd.lth.se (Joergen Haegg) writes:

   A question about how to fork() in SYSV.

   I want to fork, and the parentprocess should continue without
   doing a wait().
   When the child exits, it is transformed into a zombieprocess.
   The zombie exists until the parent exits.
   This is as it should be according to SVID.

   How do I avoid getting this zombie?

   The only way, am I told, is to let the child fork again and exit.
   The parent will wait() for the first child, but not the child of 
   the first child.

   The second child will not create a zombie, because the parent 
   (the first child) is dead.
   This seems a bit silly, because /etc/init forks all the time and without
   any zombies. (Ok, init is maybe a little special :-)

   Is there not a cleaner way to do this?

   -- 
   --
   Joergen Haegg				jh at efd.lth.se	postmaster at efd.lth.se
   System manager @ efd			046-107492
   Lund Institute of Technology		Sweden

In the parent do a:

signal(SIGCLD, SIG_IGN);

this prevents the creation of a zombie without having to do anything 
in the child.

Thomas
-- 
Real life:	Thomas Tornblom		Email:	thomas at uplog.se
Snail mail:	TeleLOGIC Uppsala AB		Phone:	+46 18 189406
		Box 1218			Fax:	+46 18 132039
		S - 751 42 Uppsala, Sweden



More information about the Comp.unix.wizards mailing list