procdesc: postpone freeing the zombie' pid until procdesc is freed

Requested by:	asomers
Reviewed by:	asomers, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54592
This commit is contained in:
Konstantin Belousov
2026-01-15 07:28:31 +02:00
parent aa72df78d7
commit 09984871d8
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -979,9 +979,9 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options)
leavepgrp(p); leavepgrp(p);
if (p->p_procdesc != NULL) if (p->p_procdesc != NULL)
procdesc_reap(p); procdesc_reap(p);
sx_xunlock(&proctree_lock); else
proc_id_clear(PROC_ID_PID, p->p_pid); proc_id_clear(PROC_ID_PID, p->p_pid);
sx_xunlock(&proctree_lock);
PROC_LOCK(p); PROC_LOCK(p);
knlist_detach(p->p_klist); knlist_detach(p->p_klist);
+4
View File
@@ -270,6 +270,9 @@ procdesc_free(struct procdesc *pd)
KASSERT((pd->pd_flags & PDF_CLOSED), KASSERT((pd->pd_flags & PDF_CLOSED),
("procdesc_free: !PDF_CLOSED")); ("procdesc_free: !PDF_CLOSED"));
if (pd->pd_pid != -1)
proc_id_clear(PROC_ID_PID, pd->pd_pid);
knlist_destroy(&pd->pd_selinfo.si_note); knlist_destroy(&pd->pd_selinfo.si_note);
PROCDESC_LOCK_DESTROY(pd); PROCDESC_LOCK_DESTROY(pd);
free(pd, M_PROCDESC); free(pd, M_PROCDESC);
@@ -389,6 +392,7 @@ procdesc_close(struct file *fp, struct thread *td)
*/ */
pd->pd_proc = NULL; pd->pd_proc = NULL;
p->p_procdesc = NULL; p->p_procdesc = NULL;
pd->pd_pid = -1;
procdesc_free(pd); procdesc_free(pd);
/* /*