kern/108390: wait4() erroneously waits for all children when SIGCHLD is SIG_IGN

Alan Ferrency alan at pair.com
Thu Feb 1 16:40:27 UTC 2007


The following reply was made to PR kern/108390; it has been noted by GNATS.

From: Alan Ferrency <alan at pair.com>
To: bug-followup at FreeBSD.org
Cc: Alan Ferrency <alan at pair.com>
Subject: Re: kern/108390: wait4() erroneously waits for all children when
 SIGCHLD is SIG_IGN
Date: Thu, 1 Feb 2007 11:38:48 -0500 (EST)

 Perusing the source of sys/kern/kern_exit.c on the FreeBSD CVSWEB, I
 believe I found the problematic change.
 
 The change is in exit1() and not in wait4() or related functions. The
 change is between r1.156 and r1.157, as shown here:
 
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_exit.c.diff?r1=1.156&r2=1.157&f=h
 
 
 Here, exit1() was modified so that if a process has SIGCHLD set to
 SIG_IGN, and it calls exit(), then this is treated the same as if
 SA_NOCLDWAIT was set. That is: the parent process is not notified that
 the child exited; instead, pid 1 is notified.
 
 I modified my test script to output the return value and errno of the
 failing wait4() call, and it verifies that when waiting too long for the
 short-running process, wait4() is returning with ENOCHLD (no child
 processes) and not because it received notification of a child process
 exiting.
 
 The current implementation makes it invalid for any process to execute
 a blocking wait() if it is ignoring SIGCHLD. This does not seem
 correct. Just because I don't want to receive a signal when my
 children exit, this does not mean I won't want to ask them whether
 they're alive or not.
 
 Alan Ferrency
 
 


More information about the freebsd-bugs mailing list