[PATCH] Handle SIGCHLD better in process_standard, remove process_{onefork,prefork}

Jeremy Allison jra at samba.org
Mon Mar 2 17:58:03 MST 2015

On Tue, Mar 03, 2015 at 01:05:20PM +1300, Andrew Bartlett wrote:
> The difference is that this code knows what the PID is for waitpid(),
> rather than using a PID of -1: 	while ((pid = sys_waitpid(-1, &status,
> WNOHANG)) > 0) {
> 		bool unclean_shutdown = False;
> The issue with waitpid() of -1, as I understand it, is that no other
> waitpid (expecting a specific pid) can be called in that codebase,
> because this one will preempt the more specific call, say in
> samba_runcmd_recv(). 

The advantage to using waitpid(-1...WNOHANG) in this
case is it also reaps zombies that we might not have
been expecting.

Now we should always know about our children, and
catch them when they terminate - but in the long and
glorious history of Samba there might have been
occassions where we weren't so dilligent, and leaked
zombies like a bad episode of "The Walking Dead".

Current code stops that from happening again, should
(god forbid :-) we make another mistake :-).

More information about the samba-technical mailing list