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:
Eitan Adler 2012-05-30 03:55:44 +00:00
parent 5e4cc10b6d
commit 35f8ab70be
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=236286

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;