summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_process.c
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2012-04-12 14:40:41 +0000
committerkettenis <kettenis@openbsd.org>2012-04-12 14:40:41 +0000
commit058657a11122f0712e9a19f23ffe31a7967dc233 (patch)
tree3bf8382f8b67d829eef10946a67fdf9ea1a2c4cc /sys/kern/sys_process.c
parentClarify thread-localness in the wake of rfork's removal (diff)
downloadwireguard-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.c6
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)