spawning a child by double forking

Brian Litzinger brian at apt.UUCP
Wed Jul 5 18:21:42 AEST 1989


>From article <JEFFL.89Jul4084155 at berick.uucp>, by jeffl at berick.uucp (Jeff Lawhorn):
> ]  Thus far, two people have suggested that one way to prevent zombie
> ]processes from building up is to fork twice instead of once when
> ]starting a child -- the child of the first fork forks again and then
> ]immediately exits.  The "grandchild" which results is inherited by
> ]init, which takes care of cleanup, and the parent therefore doesn't
> ]have to worry about cleaning up.
> 
> There is a better way to do this.  Have the parent ignore the
> signal SIGCLD.  My man page for signal states:
> 

It is interesting how these discussions can become circular. 8-)

I believe this discussion originated from my posting regarding
a problem I was having with the creation of zombie processes.

Ignoring SIGCLD is a wonderful solution for people running
System V.  Unfortunately, ignoring SIGCHLD in most BSD systems will
not produce the same result.

Note:  BSD SIGCHLD generally equals System V SIGCLD.

The reasoning behind the double forking is that it is a more portable
solution than ignoring SIGCLD.

The discussion then seemed to move to the effeciency of double forking
and maybe using vfork().

<>  Brian Litzinger @ APT Technology Inc., San Jose, CA
<>  UUCP:  {apple,sun,pyramid}!daver!apt!brian    brian at apt.UUCP
<>  VOICE: 408 370 9077      FAX: 408 370 9291



More information about the Comp.unix.questions mailing list