1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

union wait is dead, ancient history; stop using it

ok deraadt@
This commit is contained in:
guenther 2011-11-06 01:43:50 +00:00
parent adcd8f604d
commit 5105d5e33f
3 changed files with 21 additions and 20 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proc.c,v 1.21 2009/10/27 23:59:21 deraadt Exp $ */
/* $OpenBSD: proc.c,v 1.22 2011/11/06 01:43:50 guenther Exp $ */
/* $NetBSD: proc.c,v 1.9 1995/04/29 23:21:33 mycroft Exp $ */
/*-
@ -75,13 +75,13 @@ pchild(int notused)
int pid;
extern int insource;
int save_errno = errno;
union wait w;
int w;
int jobflags;
struct rusage ru;
loop:
errno = 0; /* reset, just in case */
pid = wait3(&w.w_status,
pid = wait3(&w,
(setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG), &ru);
if (pid <= 0) {
@ -103,7 +103,7 @@ found:
pp->p_flags &= ~(PRUNNING | PSTOPPED | PREPORTED);
if (WIFSTOPPED(w)) {
pp->p_flags |= PSTOPPED;
pp->p_reason = w.w_stopsig;
pp->p_reason = WSTOPSIG(w);
}
else {
if (pp->p_flags & (PTIME | PPTIME) || adrof(STRtime))
@ -111,16 +111,16 @@ found:
pp->p_rusage = ru;
if (WIFSIGNALED(w)) {
if (w.w_termsig == SIGINT)
if (WTERMSIG(w) == SIGINT)
pp->p_flags |= PINTERRUPTED;
else
pp->p_flags |= PSIGNALED;
if (w.w_coredump)
if (WCOREDUMP(w))
pp->p_flags |= PDUMPED;
pp->p_reason = w.w_termsig;
pp->p_reason = WTERMSIG(w);
}
else {
pp->p_reason = w.w_retcode;
pp->p_reason = WEXITSTATUS(w);
if (pp->p_reason != 0)
pp->p_flags |= PAEXITED;
else

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pl_1.c,v 1.9 2009/10/27 23:59:27 deraadt Exp $ */
/* $OpenBSD: pl_1.c,v 1.10 2011/11/06 01:43:50 guenther Exp $ */
/* $NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $ */
/*
@ -124,13 +124,13 @@ void
child(n)
int n __attribute__((unused));
{
union wait status;
int status;
int pid;
int save_errno = errno;
(void) signal(SIGCHLD, SIG_DFL);
do {
pid = wait3((int *)&status, WNOHANG, (struct rusage *)0);
pid = waitpid((pid_t)-1, &status, WNOHANG);
if (pid < 0 || (pid > 0 && !WIFSTOPPED(status)))
hasdriver = 0;
} while (pid > 0);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sched.c,v 1.13 2004/10/21 20:57:08 millert Exp $ */
/* $OpenBSD: sched.c,v 1.14 2011/11/06 01:43:50 guenther Exp $ */
/*
* Copyright (c) 1990 Jan-Simon Pendry
@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)sched.c 8.1 (Berkeley) 6/6/93
* $Id: sched.c,v 1.13 2004/10/21 20:57:08 millert Exp $
* $Id: sched.c,v 1.14 2011/11/06 01:43:50 guenther Exp $
*/
/*
@ -54,7 +54,7 @@ struct pjob {
pid_t pid; /* Process ID of job */
cb_fun cb_fun; /* Callback function */
void *cb_closure; /* Closure for callback */
union wait w; /* Status filled in by sigchld */
int w; /* Status filled in by sigchld */
void *wchan; /* Wait channel */
};
@ -193,24 +193,24 @@ wakeup_task(int rc, int term, void *cl)
void
sigchld(int sig)
{
union wait w;
int w;
int save_errno = errno;
pid_t pid;
#ifdef SYS5_SIGNALS
if ((pid = wait(&w)) > 0) {
#else
while ((pid = wait3((int *) &w, WNOHANG, (struct rusage *) 0)) > 0) {
while ((pid = waitpid((pid_t)-1, &w, WNOHANG)) > 0) {
#endif /* SYS5_SIGNALS */
pjob *p, *p2;
if (WIFSIGNALED(w))
plog(XLOG_ERROR, "Process %ld exited with signal %ld",
(long)pid, w.w_termsig);
(long)pid, WTERMSIG(w));
#ifdef DEBUG
else
dlog("Process %ld exited with status %ld",
(long)pid, w.w_retcode);
(long)pid, WEXITSTATUS(w));
#endif /* DEBUG */
for (p = FIRST(pjob, &proc_wait_list);
@ -263,8 +263,9 @@ do_task_notify(void)
* Do callback if it exists
*/
if (p->cb_fun)
(*p->cb_fun)(p->w.w_retcode,
p->w.w_termsig, p->cb_closure);
(*p->cb_fun)(WIFEXITED(p->w) ? WEXITSTATUS(p->w) : 0,
WIFSIGNALED(p->w) ? WTERMSIG(p->w) : 0,
p->cb_closure);
free((void *)p);
}