-/* $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 $ */
/*
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) {
if (SCARG(uap, options) &~ (WUNTRACED|WNOHANG|WCONTINUED))
return (EINVAL);
+ options |= WEXITED | WTRAPPED;
if (SCARG(uap, pid) == WAIT_MYPGRP) {
idtype = P_PGID;
}
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));
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);
-/* $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 $ */
/*
* 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,
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