summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-05-30 03:55:44 +0000
committereadler <eadler@FreeBSD.org>2012-05-30 03:55:44 +0000
commit336581c2f4022bc82b73d00e4b17bb842bcdf0bf (patch)
tree7630bcd74112512560d6d9b409c3d88da80a8c8f /usr.bin
parent3f451eb3b163781d5464a085d3aa219a7b232861 (diff)
downloadFreeBSD-src-336581c2f4022bc82b73d00e4b17bb842bcdf0bf.zip
FreeBSD-src-336581c2f4022bc82b73d00e4b17bb842bcdf0bf.tar.gz
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
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/popen.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c
index 18bf7e5..c4d1746 100644
--- a/usr.bin/mail/popen.c
+++ b/usr.bin/mail/popen.c
@@ -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;
OpenPOWER on IntegriCloud