Date: Thu, 14 Jul 2016 02:25:29 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302799 - head/usr.bin/mail Message-ID: <201607140225.u6E2PTtk071060@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Thu Jul 14 02:25:29 2016 New Revision: 302799 URL: https://svnweb.freebsd.org/changeset/base/302799 Log: mail(1): Bring some fixes from other BSDs. Fix missing forked job changes from r302776 in wait_child(). Obtained from: NetBSD Modified: head/usr.bin/mail/popen.c Modified: head/usr.bin/mail/popen.c ============================================================================== --- head/usr.bin/mail/popen.c Thu Jul 14 01:16:07 2016 (r302798) +++ head/usr.bin/mail/popen.c Thu Jul 14 02:25:29 2016 (r302799) @@ -362,21 +362,30 @@ int wait_status; int wait_child(pid_t pid) { - sigset_t nset, oset; struct child *cp; + sigset_t nset, oset; + pid_t rv = 0; (void)sigemptyset(&nset); (void)sigaddset(&nset, SIGCHLD); - (void)sigprocmask(SIG_BLOCK, &nset, &oset); - + (void)sigprocmask(SIG_BLOCK, &nset, &oset); + /* + * If we have not already waited on the pid (via sigchild) + * wait on it now. Otherwise, use the wait status stashed + * by sigchild. + */ cp = findchild(pid, 1); - - while (!cp->done) - (void)sigsuspend(&oset); - wait_status = cp->status; - delchild(cp); + if (cp == NULL || !cp->done) + rv = waitpid(pid, &wait_status, 0); + else + wait_status = cp->status; + if (cp != NULL) + delchild(cp); (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return ((WIFEXITED(wait_status) && WEXITSTATUS(wait_status)) ? -1 : 0); + if (rv == -1 || (WIFEXITED(wait_status) && WEXITSTATUS(wait_status))) + return -1; + else + return 0; } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607140225.u6E2PTtk071060>