diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2012-04-12 14:40:42 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2012-04-12 14:40:42 +0000 |
commit | 3219f9f3989238e48d2c6eeb05a2431877fe5d8d (patch) | |
tree | f304e86a8afc1d2735be38c039a6d3c0f9a38912 /sys | |
parent | e077e67057050ae1c8f4faac4ba0f57ae7ed74e1 (diff) |
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')
-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) |