From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,782002c31f9c8f6c X-Google-Attributes: gidfee84,public From: Steve VanDevender Subject: Re: Zombies are haunting me! HELP! Date: 1998/05/27 Message-ID: #1/1 X-Deja-AN: 357082305 References: <6ken58$9e0@examiner.concentric.net> X-Complaints-To: usenet@news.uoregon.edu X-Trace: pith.uoregon.edu 896303043 26734 (None) 128.223.32.56 Organization: University of Oregon, Eugene Newsgroups: comp.unix.osf.osf1 clark@knowideas.com (William Clark) writes: > Hello there, > > I am writing c code on a DEC Alpha box running DEC Unix. > > I have created a daemon that forks a child to receive a file > from a remote process. > > Everything works great EXCEPT that I am collecting a zombie > for each terminated child process. > > I am using the signal function with SIGCHLD,SIG_IGN params before > I start the loop that waits for a sockets connection and forks > the child. > > I thought that would prevent zombies. > > Any ideas would be appreciated. Thanks in advance. > > billc Quite simply, the parent must issue a wait() system call for each child that it forks. A child will remain in a zombie state until the parent collects its exit status with wait() (or wait3() or wait4(); see "man 2 wait" for additional information). Ignoring SIGCHLD will not prevent zombies; in fact, it will be more likely to preserve them. Normally you would want to catch SIGCHLD and issue a wait() from in the signal handler if you want to be able to handle child exits asynchronously. -- Steve VanDevender "I ride the big iron" http://jcomm.uoregon.edu/~stevev stevev@hexadecimal.uoregon.edu PGP keyprint 4AD7AF61F0B9DE87 522902969C0A7EE8 "bash awk grep perl sed df du, du-du du-du, vi troff su fsck rm * halt LART LART LART!" -- the Swedish BOFH