Re: fork problems (zombie children)

Robert L Krawitz (
Wed, 8 May 1996 09:30:00 -0400

Date: Mon, 6 May 1996 18:22:11 -0500 (CDT)
From: Thomas Zerucha <>

What am I doing wrong? The following program:

#include <signal.h>
#include <sys/wait.h>
for(;;) {
if( !fork() ) {
exit(0); /* child, exit immediately */

when run with PID=8704 creates children that stay undead until the parent
process terminates, e.g. from "ps -x":

You need to wait() on the children (from the parent) to reap them.
Otherwise they stay around so that the parent can grab their exit