The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=109b9f48ec4e26e12ab5765747f3d5156aa62406
commit 109b9f48ec4e26e12ab5765747f3d5156aa62406 Author: Konstantin Belousov <[email protected]> AuthorDate: 2026-01-08 04:03:51 +0000 Commit: Konstantin Belousov <[email protected]> CommitDate: 2026-01-25 15:53:22 +0000 kern/kern_exit.c: define the exterror category for exit/wait Convert EINVALs in kern_exit.c into EXTERRORs. Reviewed by: asomers, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54592 --- sys/kern/kern_exit.c | 39 +++++++++++++++++++++++++-------------- sys/sys/exterr_cat.h | 1 + 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 44d2bddf53fb..db6e91f00534 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,10 +37,12 @@ #include "opt_ddb.h" #include "opt_ktrace.h" +#define EXTERR_CATEGORY EXTERR_CAT_PROCEXIT #include <sys/systm.h> #include <sys/acct.h> /* for acct_process() function prototype */ #include <sys/capsicum.h> #include <sys/eventhandler.h> +#include <sys/exterrvar.h> #include <sys/filedesc.h> #include <sys/jail.h> #include <sys/kernel.h> @@ -1269,6 +1271,26 @@ report_alive_proc(struct thread *td, struct proc *p, siginfo_t *siginfo, PROC_UNLOCK(p); } +static int +wait6_checkopt(int options) +{ + /* If we don't know the option, just return. */ + if ((options & ~(WUNTRACED | WNOHANG | WCONTINUED | WNOWAIT | + WEXITED | WTRAPPED | WLINUXCLONE)) != 0) + return (EXTERROR(EINVAL, "Unknown options %#jx", options)); + if ((options & (WEXITED | WUNTRACED | WCONTINUED | WTRAPPED)) == 0) { + /* + * We will be unable to find any matching processes, + * because there are no known events to look for. + * Prefer to return error instead of blocking + * indefinitely. + */ + return (EXTERROR(EINVAL, + "Cannot match processes %#jx", options)); + } + return (0); +} + int kern_wait6(struct thread *td, idtype_t idtype, id_t id, int *status, int options, struct __wrusage *wrusage, siginfo_t *siginfo) @@ -1291,20 +1313,9 @@ kern_wait6(struct thread *td, idtype_t idtype, id_t id, int *status, idtype = P_PGID; } - /* If we don't know the option, just return. */ - if ((options & ~(WUNTRACED | WNOHANG | WCONTINUED | WNOWAIT | - WEXITED | WTRAPPED | WLINUXCLONE)) != 0) - return (EINVAL); - if ((options & (WEXITED | WUNTRACED | WCONTINUED | WTRAPPED)) == 0) { - /* - * We will be unable to find any matching processes, - * because there are no known events to look for. - * Prefer to return error instead of blocking - * indefinitely. - */ - return (EINVAL); - } - + error = wait6_checkopt(options); + if (error != 0) + return (error); loop: if (q->p_flag & P_STATCHILD) { PROC_LOCK(q); diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h index daf0419754b7..015eb6a1ae76 100644 --- a/sys/sys/exterr_cat.h +++ b/sys/sys/exterr_cat.h @@ -38,6 +38,7 @@ #define EXTERR_CAT_FUSE_VFS 13 #define EXTERR_CAT_FUSE_DEVICE 14 #define EXTERR_CAT_FORK 15 +#define EXTERR_CAT_PROCEXIT 16 #endif
