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;