defunct processes even after signal(...wait())

Guy Harris guy at auspex.auspex.com
Sat Sep 23 05:09:39 AEST 1989


>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 <sys/wait.h>

	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.



More information about the Comp.unix.wizards mailing list