From owner-freebsd-questions Tue Feb 17 12:23:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA14344 for freebsd-questions-outgoing; Tue, 17 Feb 1998 12:23:30 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from gdi.uoregon.edu (gdi.uoregon.edu [128.223.170.30]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA14295 for ; Tue, 17 Feb 1998 12:23:05 -0800 (PST) (envelope-from dwhite@gdi.uoregon.edu) Received: from localhost (dwhite@localhost) by gdi.uoregon.edu (8.8.7/8.8.8) with SMTP id MAA12437; Tue, 17 Feb 1998 12:22:46 -0800 (PST) (envelope-from dwhite@gdi.uoregon.edu) Date: Tue, 17 Feb 1998 12:22:45 -0800 (PST) From: Doug White Reply-To: Doug White To: vel@ns.kbsu.ru cc: questions@FreeBSD.ORG Subject: Re: Zombie processes In-Reply-To: <199802171635.TAA01302@hub.kbsu.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 17 Feb 1998, Charlie wrote: > I have a small trouble with my program under FreeBSD. I do fork() to > create new process, and new process must do something and exit, but > parent process must continue. The simplest program looks like this: > > #include > #include > > main() > { > if (!fork()) > { > printf("This is child, exiting ...\n"); > return; > } > while(1); > } > > The created child process must write message and exit, but it doesn't exit > correctly. It hangs like "zombie" process until parent process exits. > > Why it happens ? Is there any way to solve or walk around this problem ? This is correct behavior for BSD programs. It's often not desired but correct in terms of the process model. If you want to reap children, add a signal handler for SIGCHLD to call wait(). Doug White | University of Oregon Internet: dwhite@resnet.uoregon.edu | Residence Networking Assistant http://gladstone.uoregon.edu/~dwhite | Computer Science Major To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message