mail(1): Bring some fixes from other BSDs.
Fix missing forked job changes from r302776 in wait_child(). Obtained from: NetBSD
This commit is contained in:
parent
8cabd541f7
commit
92fa728bb1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302799
@ -362,21 +362,30 @@ int wait_status;
|
|||||||
int
|
int
|
||||||
wait_child(pid_t pid)
|
wait_child(pid_t pid)
|
||||||
{
|
{
|
||||||
sigset_t nset, oset;
|
|
||||||
struct child *cp;
|
struct child *cp;
|
||||||
|
sigset_t nset, oset;
|
||||||
|
pid_t rv = 0;
|
||||||
|
|
||||||
(void)sigemptyset(&nset);
|
(void)sigemptyset(&nset);
|
||||||
(void)sigaddset(&nset, SIGCHLD);
|
(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);
|
cp = findchild(pid, 1);
|
||||||
|
if (cp == NULL || !cp->done)
|
||||||
while (!cp->done)
|
rv = waitpid(pid, &wait_status, 0);
|
||||||
(void)sigsuspend(&oset);
|
else
|
||||||
wait_status = cp->status;
|
wait_status = cp->status;
|
||||||
delchild(cp);
|
if (cp != NULL)
|
||||||
|
delchild(cp);
|
||||||
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
|
(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user