git: 2e3ba764b21f - main - wait4(2): add kern_wait4
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 11:08:08 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=2e3ba764b21f8f48ea2d48c0118a8f8e2eb4dd41
commit 2e3ba764b21f8f48ea2d48c0118a8f8e2eb4dd41
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-09 11:07:57 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-09 11:07:57 +0000
wait4(2): add kern_wait4
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Pull Request: https://github.com/freebsd/freebsd-src/pull/2284
---
sys/kern/kern_exit.c | 20 ++++++++++++++------
sys/sys/syscallsubr.h | 2 ++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index fa1721fbaede..748164fed948 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -898,19 +898,27 @@ owait(struct thread *td, struct owait_args *uap __unused)
*/
int
sys_wait4(struct thread *td, struct wait4_args *uap)
+{
+ return (kern_wait4(td, uap->pid, uap->status, uap->options,
+ uap->rusage));
+}
+
+int
+kern_wait4(struct thread *td, int pid, int *statusp, int options,
+ struct rusage *rusage)
{
struct rusage ru, *rup;
int error, status;
- if (uap->rusage != NULL)
+ if (rusage != NULL)
rup = &ru;
else
rup = NULL;
- error = kern_wait(td, uap->pid, &status, uap->options, rup);
- if (uap->status != NULL && error == 0 && td->td_retval[0] != 0)
- error = copyout(&status, uap->status, sizeof(status));
- if (uap->rusage != NULL && error == 0 && td->td_retval[0] != 0)
- error = copyout(&ru, uap->rusage, sizeof(struct rusage));
+ error = kern_wait(td, pid, &status, options, rup);
+ if (statusp != NULL && error == 0 && td->td_retval[0] != 0)
+ error = copyout(&status, statusp, sizeof(status));
+ if (rusage != NULL && error == 0 && td->td_retval[0] != 0)
+ error = copyout(&ru, rusage, sizeof(struct rusage));
return (error);
}
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 872191c6b3d3..59ec3640d3ff 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -472,6 +472,8 @@ int kern_utimensat(struct thread *td, int fd, const char *path,
enum uio_seg tptrseg, int flag);
int kern_wait(struct thread *td, pid_t pid, int *status, int options,
struct rusage *rup);
+int kern_wait4(struct thread *td, int pid, int *statusp, int options,
+ struct rusage *rusage);
int kern_wait6(struct thread *td, enum idtype idtype, id_t id, int *status,
int options, struct __wrusage *wrup, siginfo_t *sip);
int kern_writev(struct thread *td, int fd, struct uio *auio);