From 35f8ab70be58c726fec4b0156cd9ec880462482a Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Wed, 30 May 2012 03:55:44 +0000 Subject: [PATCH] Fix likely race condition if wait_child() is interrupted by sigchild() PR: bin/102834 Submitted by: Andreas Longwitz Approved by: cperciva MFC after: 2 weeks --- usr.bin/mail/popen.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 18bf7e5a3aa5..c4d17461e48d 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;