From: guenther Date: Mon, 19 Dec 2022 00:22:11 +0000 (+0000) Subject: Add WTRAPPED opiton for waitid(2) to control whether CMD_TRAPPED X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=60972c460a5aa9e23ce1b2da9adc4d37596fff7f;p=openbsd Add WTRAPPED opiton for waitid(2) to control whether CMD_TRAPPED state changes are reported. That's the 6th bit, so switch to hex constants. Adjust #if tests for consistency ok kettenis@ --- diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 2f1708609fb..afdba76e21d 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.208 2022/12/05 23:18:37 deraadt Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.209 2022/12/19 00:22:12 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -517,7 +517,8 @@ loop: proc_finish_wait(q, p); return (0); } - if (pr->ps_flags & PS_TRACED && + if ((options & WTRAPPED) && + pr->ps_flags & PS_TRACED && (pr->ps_flags & PS_WAITED) == 0 && pr->ps_single && pr->ps_single->p_stat == SSTOP && (pr->ps_single->p_flag & P_SUSPSINGLE) == 0) { @@ -636,6 +637,7 @@ sys_wait4(struct proc *q, void *v, register_t *retval) if (SCARG(uap, options) &~ (WUNTRACED|WNOHANG|WCONTINUED)) return (EINVAL); + options |= WEXITED | WTRAPPED; if (SCARG(uap, pid) == WAIT_MYPGRP) { idtype = P_PGID; @@ -652,7 +654,7 @@ sys_wait4(struct proc *q, void *v, register_t *retval) } error = dowait6(q, idtype, id, - SCARG(uap, status) ? &status : NULL, options | WEXITED, + SCARG(uap, status) ? &status : NULL, options, SCARG(uap, rusage) ? &ru : NULL, NULL, retval); if (error == 0 && *retval > 0 && SCARG(uap, status)) { error = copyout(&status, SCARG(uap, status), sizeof(status)); @@ -681,9 +683,9 @@ sys_waitid(struct proc *q, void *v, register_t *retval) int options = SCARG(uap, options); int error; - if (options &~ (WSTOPPED|WCONTINUED|WEXITED|WNOHANG|WNOWAIT)) + if (options &~ (WSTOPPED|WCONTINUED|WEXITED|WTRAPPED|WNOHANG|WNOWAIT)) return (EINVAL); - if ((options & (WSTOPPED|WCONTINUED|WEXITED)) == 0) + if ((options & (WSTOPPED|WCONTINUED|WEXITED|WTRAPPED)) == 0) return (EINVAL); if (idtype != P_ALL && idtype != P_PID && idtype != P_PGID) return (EINVAL); diff --git a/sys/sys/wait.h b/sys/sys/wait.h index 89af5f939e9..d838c1be73a 100644 --- a/sys/sys/wait.h +++ b/sys/sys/wait.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wait.h,v 1.19 2022/10/25 16:08:26 kettenis Exp $ */ +/* $OpenBSD: wait.h,v 1.20 2022/12/19 00:22:11 guenther Exp $ */ /* $NetBSD: wait.h,v 1.11 1996/04/09 20:55:51 cgd Exp $ */ /* @@ -75,16 +75,15 @@ * about them is returned. WNOWAIT only requests information about zombie, * leaving the proc around, available for later waits. */ -#define WNOHANG 1 /* don't hang in wait */ -#define WUNTRACED 2 /* tell about stopped, untraced children */ +#define WNOHANG 0x01 /* don't hang in wait */ +#define WUNTRACED 0x02 /* report stopped-by-signal processes */ +#define WCONTINUED 0x08 /* report job control continued processes */ +#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE >= 420 +#define WEXITED 0x04 /* report exited processes */ #define WSTOPPED WUNTRACED -#define WCONTINUED 8 /* report a job control continued process */ -#if __POSIX_VISIBLE >= 200809 || _XPG_VISIBLE -#define WEXITED 4 /* wait for exited processes */ -#define WNOWAIT 16 /* poll only */ -#endif +#define WNOWAIT 0x10 /* poll only */ +#define WTRAPPED 0x20 /* report stopped-by-tracing processes */ -#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE typedef enum { P_ALL, P_PGID, @@ -108,7 +107,7 @@ struct rusage; /* forward declaration */ pid_t wait(int *); pid_t waitpid(pid_t, int *, int); -#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE +#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE >= 420 int waitid(idtype_t, id_t, siginfo_t *, int); #endif #if __BSD_VISIBLE