Xref: utzoo comp.unix.questions:16503 comp.unix.wizards:18308 Path: utzoo!censor!geac!jtsv16!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: defunct processes even after signal(...wait()) Keywords: signal , wait and defunct processes ... Message-ID: <2482@auspex.auspex.com> Date: 22 Sep 89 19:09:39 GMT References: <230@cerc.wvu.wvnet.edu.edu> <1183@virtech.UUCP> Reply-To: guy@auspex.auspex.com (Guy Harris) Distribution: usa Organization: Auspex Systems, Santa Clara Lines: 26 >It *sounds like* you are loosing some of the sigchlds. Since you are >running under the sun os I would recommend using the BSD signal handling >mechanisms which should handle the problem. Since he's running under SunOS, unless he's building his code in the System V environment he *is* using the BSD signal handling mechanisms, even if he's using "signal()". (Yes, "signal()" in BSD, and the BSD environment of SunOS, has BSD rather than V7 semantics.) The problem is that there isn't any guarantee in BSD that one SIGCHLD is delivered for each child process. The SIGCHLD handler should loop until there are no zombies to be picked up. For example, this is the SIGCHLD handler used in the "script" command (simplified a bit): #include finish() { union wait status; while (wait3(&status, WNOHANG, 0) > 0) ; } The WNOHANG makes sure it doesn't block waiting for children that haven't exited yet.