Fix likely race condition if wait_child() is interrupted by sigchild()

PR:		bin/102834
Submitted by:	Andreas Longwitz <longwitz@incore.de>
Approved by:	cperciva
MFC after:	2 weeks
This commit is contained in:
eadler 2012-05-30 03:55:44 +00:00
parent 3f451eb3b1
commit 336581c2f4

View File

@ -336,12 +336,14 @@ int
wait_child(int pid)
{
sigset_t nset, oset;
struct child *cp = findchild(pid);
struct child *cp;
(void)sigemptyset(&nset);
(void)sigaddset(&nset, SIGCHLD);
(void)sigprocmask(SIG_BLOCK, &nset, &oset);
cp = findchild(pid);
while (!cp->done)
(void)sigsuspend(&oset);
wait_status = cp->status;