Xref: utzoo comp.unix.questions:11671 comp.unix.wizards:14659 comp.unix.xenix:4936 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdcad!sun!arabian!jamesa From: jamesa@arabian.Sun.COM (JD Allen) Newsgroups: comp.unix.questions,comp.unix.wizards,comp.unix.xenix Subject: Re: Getting rid of a process Summary: You don't need to wait for a bastard Keywords: defunct process Message-ID: <89504@sun.uucp> Date: 13 Feb 89 00:51:14 GMT References: <102@avatar.UUCP> Sender: news@sun.uucp Distribution: usa Lines: 27 In article <102@avatar.UUCP>, kory@avatar.UUCP (Kory Hamzeh) writes: > I have written an application which forks and execs off many subtasks. > The main process (the parent which does all of the forks) can not > do a wait() because I can't get blocked for anything. Well, this results > in a lot of "" processes in the process table when the child > exits. Simply replace: if (fork() == 0) run_child_code(); With a lintable version of: if (fork() == 0) fork() ? _exit() : run_child_code(); else wait(0); /* reap the "dummy" process */ When your orphaned grandchild exits it will now be reaped by the Grim Reaper. "Bastards" don't become "zombies". (Holy metaphor, Batman!) (On the other hand, "morally", if a process is worth running, its exit status is worth inspecting. You can get it "asynchronously" with SIGCHLD and/or wait3().) -- James Allen