diff options
author | 2012-04-12 14:40:41 +0000 | |
---|---|---|
committer | 2012-04-12 14:40:41 +0000 | |
commit | 058657a11122f0712e9a19f23ffe31a7967dc233 (patch) | |
tree | 3bf8382f8b67d829eef10946a67fdf9ea1a2c4cc /sys/kern/sys_process.c | |
parent | Clarify thread-localness in the wake of rfork's removal (diff) | |
download | wireguard-openbsd-058657a11122f0712e9a19f23ffe31a7967dc233.tar.xz wireguard-openbsd-058657a11122f0712e9a19f23ffe31a7967dc233.zip |
If the "main" thread exits it stays around but unlinks itself from the
threads list. Calling TAILQ_NEXT on them is a bad idea and will panic
the kernel. So check the P_WEXIT flag and pretend the thread doesn't
exist if it is set. Also make PT_GET_THREAD_FIRST return the first
thread on the threads list instead of the "main" thread, such that you
can actually keep enumerating the threads in this case.
ok guenther@, miod@
Diffstat (limited to 'sys/kern/sys_process.c')
-rw-r--r-- | sys/kern/sys_process.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 0d5248d29c0..480f42dd0e3 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.54 2012/04/12 12:09:05 kettenis Exp $ */ +/* $OpenBSD: sys_process.c,v 1.55 2012/04/12 14:40:41 kettenis Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -308,11 +308,13 @@ sys_ptrace(struct proc *p, void *v, register_t *retval) return (error); t = pfind(pts.pts_tid - THREAD_PID_OFFSET); - if (t == NULL) + if (t == NULL || ISSET(t->p_flag, P_WEXIT)) return (ESRCH); if (t->p_p != tr) return (EINVAL); t = TAILQ_NEXT(t, p_thr_link); + } else { + t = TAILQ_FIRST(&tr->ps_threads); } if (t == NULL) |