diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_exit.c | 54 | ||||
-rw-r--r-- | sys/kern/kern_resource.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_time.c | 4 |
3 files changed, 21 insertions, 41 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 9d246c999f9..fda5e769877 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.128 2013/10/08 03:50:07 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.129 2013/10/25 04:42:48 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -439,9 +439,6 @@ reaper(void) } } -int dowait4(struct proc *, pid_t, int *, int, struct rusage *, - register_t *); - int sys_wait4(struct proc *q, void *v, register_t *retval) { @@ -452,10 +449,14 @@ sys_wait4(struct proc *q, void *v, register_t *retval) syscallarg(struct rusage *) rusage; } */ *uap = v; struct rusage ru; - int error; + int status, error; - error = dowait4(q, SCARG(uap, pid), SCARG(uap, status), + error = dowait4(q, SCARG(uap, pid), + SCARG(uap, status) ? &status : NULL, SCARG(uap, options), SCARG(uap, rusage) ? &ru : NULL, retval); + if (error == 0 && SCARG(uap, status)) { + error = copyout(&status, SCARG(uap, status), sizeof(status)); + } if (error == 0 && SCARG(uap, rusage)) { error = copyout(&ru, SCARG(uap, rusage), sizeof(ru)); } @@ -469,7 +470,7 @@ dowait4(struct proc *q, pid_t pid, int *statusp, int options, int nfound; struct process *pr; struct proc *p; - int status, error; + int error; if (pid == 0) pid = -q->p_p->ps_pgid; @@ -499,13 +500,8 @@ loop: if (p->p_stat == SZOMB) { retval[0] = p->p_pid; - if (statusp != NULL) { - status = p->p_xstat; /* convert to int */ - error = copyout(&status, - statusp, sizeof(status)); - if (error) - return (error); - } + if (statusp != NULL) + *statusp = p->p_xstat; /* convert to int */ if (rusage != NULL) memcpy(rusage, pr->ps_ru, sizeof(*rusage)); proc_finish_wait(q, p); @@ -518,13 +514,9 @@ loop: atomic_setbits_int(&pr->ps_flags, PS_WAITED); retval[0] = p->p_pid; - if (statusp != NULL) { - status = W_STOPCODE(pr->ps_single->p_xstat); - error = copyout(&status, statusp, - sizeof(status)); - } else - error = 0; - return (error); + if (statusp != NULL) + *statusp = W_STOPCODE(pr->ps_single->p_xstat); + return (0); } if (p->p_stat == SSTOP && (pr->ps_flags & PS_WAITED) == 0 && @@ -534,25 +526,17 @@ loop: atomic_setbits_int(&pr->ps_flags, PS_WAITED); retval[0] = p->p_pid; - if (statusp != NULL) { - status = W_STOPCODE(p->p_xstat); - error = copyout(&status, statusp, - sizeof(status)); - } else - error = 0; - return (error); + if (statusp != NULL) + *statusp = W_STOPCODE(p->p_xstat); + return (0); } if ((options & WCONTINUED) && (p->p_flag & P_CONTINUED)) { atomic_clearbits_int(&p->p_flag, P_CONTINUED); retval[0] = p->p_pid; - if (statusp != NULL) { - status = _WCONTINUED; - error = copyout(&status, statusp, - sizeof(status)); - } else - error = 0; - return (error); + if (statusp != NULL) + *statusp = _WCONTINUED; + return (0); } } if (nfound == 0) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 27cef51c3c4..4ba85ea9da5 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.45 2013/09/14 03:06:41 guenther Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.46 2013/10/25 04:42:48 guenther Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -421,8 +421,6 @@ calcru(struct tusage *tup, struct timeval *up, struct timeval *sp, TIMESPEC_TO_TIMEVAL(ip, &i); } -int dogetrusage(struct proc *, int, struct rusage *); - /* ARGSUSED */ int sys_getrusage(struct proc *p, void *v, register_t *retval) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 187cb43e4ae..076d24c4132 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.84 2013/10/08 03:50:08 guenther Exp $ */ +/* $OpenBSD: kern_time.c,v 1.85 2013/10/25 04:42:48 guenther Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -48,8 +48,6 @@ struct timeval adjtimedelta; /* unapplied time correction */ -void itimerround(struct timeval *); - /* * Time of day and interval timer support. * |