Index: sys/ddb/db_ps.c =================================================================== --- sys/ddb/db_ps.c +++ sys/ddb/db_ps.c @@ -107,7 +107,7 @@ db_ps(db_expr_t addr, bool hasaddr, db_expr_t count, char *modif) { struct proc *p; - int i, j; + int i; ps_mode = modif[0] == 'a' ? PRINT_ARGS : PRINT_NONE; @@ -125,14 +125,12 @@ db_ps_proc(p); /* - * Do zombies. + * Processes such as zombies not in allproc. */ - for (i = 0; i < pidhashlock + 1 && !db_pager_quit; i++) { - for (j = i; j <= pidhash && !db_pager_quit; j += pidhashlock + 1) { - LIST_FOREACH(p, &pidhashtbl[j], p_hash) { - if (p->p_state == PRS_ZOMBIE) - db_ps_proc(p); - } + for (i = 0; i <= pidhash && !db_pager_quit; i++) { + LIST_FOREACH(p, &pidhashtbl[i], p_hash) { + if ((p->p_flag2 & P2_ALLPROC_REMOVED) != 0) + db_ps_proc(p); } } } Index: sys/kern/kern_exit.c =================================================================== --- sys/kern/kern_exit.c +++ sys/kern/kern_exit.c @@ -440,6 +440,7 @@ sx_xlock(&proctree_lock); PROC_LOCK(p); + p->p_flag2 |= P2_ALLPROC_REMOVED; p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); PROC_UNLOCK(p); Index: sys/sys/proc.h =================================================================== --- sys/sys/proc.h +++ sys/sys/proc.h @@ -811,6 +811,7 @@ MAP_STACK */ #define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled after exec */ +#define P2_ALLPROC_REMOVED 0x00002000 /* Removed from allproc list. */ /* Flags protected by proctree_lock, kept in p_treeflags. */ #define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */