diff options
-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 | ||||
-rw-r--r-- | sys/sys/proc.h | 4 | ||||
-rw-r--r-- | sys/sys/resource.h | 3 | ||||
-rw-r--r-- | sys/sys/time.h | 3 |
6 files changed, 28 insertions, 44 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. * diff --git a/sys/sys/proc.h b/sys/sys/proc.h index f774db796df..e8e7e7c198b 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.171 2013/10/08 03:50:06 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.172 2013/10/25 04:42:48 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -507,6 +507,8 @@ void unsleep(struct proc *); void reaper(void); void exit1(struct proc *, int, int); void exit2(struct proc *); +int dowait4(struct proc *, pid_t, int *, int, struct rusage *, + register_t *); void cpu_exit(struct proc *); int fork1(struct proc *, int, int, void *, pid_t *, void (*)(void *), void *, register_t *, struct proc **); diff --git a/sys/sys/resource.h b/sys/sys/resource.h index 453aafd13f7..9ca4bb6fc92 100644 --- a/sys/sys/resource.h +++ b/sys/sys/resource.h @@ -1,4 +1,4 @@ -/* $OpenBSD: resource.h,v 1.13 2013/09/14 01:35:02 guenther Exp $ */ +/* $OpenBSD: resource.h,v 1.14 2013/10/25 04:42:48 guenther Exp $ */ /* $NetBSD: resource.h,v 1.14 1996/02/09 18:25:27 christos Exp $ */ /* @@ -113,6 +113,7 @@ extern struct loadavg averunnable; struct process; int dosetrlimit(struct proc *, u_int, struct rlimit *); int donice(struct proc *, struct process *, int); +int dogetrusage(struct proc *, int, struct rusage *); #else __BEGIN_DECLS diff --git a/sys/sys/time.h b/sys/sys/time.h index 10657011c4f..946616054b2 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -1,4 +1,4 @@ -/* $OpenBSD: time.h,v 1.34 2013/10/24 07:34:56 guenther Exp $ */ +/* $OpenBSD: time.h,v 1.35 2013/10/25 04:42:48 guenther Exp $ */ /* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */ /* @@ -292,6 +292,7 @@ int clock_gettime(struct proc *, clockid_t, struct timespec *); int timespecfix(struct timespec *); int itimerfix(struct timeval *); int itimerdecr(struct itimerval *itp, int usec); +void itimerround(struct timeval *); int settime(struct timespec *); int ratecheck(struct timeval *, const struct timeval *); int ppsratecheck(struct timeval *, int *, int); |