From 235436d6311ea5ad00edcc1e553012f0736ea86d Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 4 Apr 2024 22:24:32 +0300 Subject: [PATCH] stop_all_proc(): skip traced or signal-stoped processes Since thread_single(SINGLE_ALLPROC) ignores them since 9241ebc796c, and there is not much we can do for the debugger-controlled process. Noted by: olce Reviewed by: markj, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44638 --- sys/kern/kern_proc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 8a396e208ff..2ecc82026b3 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -3477,7 +3477,8 @@ allproc_loop: LIST_REMOVE(cp, p_list); LIST_INSERT_AFTER(p, cp, p_list); PROC_LOCK(p); - if ((p->p_flag & (P_KPROC | P_SYSTEM | P_TOTAL_STOP)) != 0) { + if ((p->p_flag & (P_KPROC | P_SYSTEM | P_TOTAL_STOP | + P_STOPPED_SIG)) != 0) { PROC_UNLOCK(p); continue; } @@ -3498,6 +3499,16 @@ allproc_loop: PROC_UNLOCK(p); continue; } + if ((p->p_flag & P_TRACED) != 0) { + /* + * thread_single() below cannot stop traced p, + * so skip it. OTOH, we cannot require + * restart because debugger might be either + * already stopped or traced as well. + */ + PROC_UNLOCK(p); + continue; + } sx_xunlock(&allproc_lock); _PHOLD(p); r = thread_single(p, SINGLE_ALLPROC);