git: a3b8ff99b546 - stable/15 - procdesc: Remove dead code

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a8124ae.44333.16ce85ac__13185.0252788112$1786848806$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=a3b8ff99b54679f2a1b5da7f8cf52992adb34840

commit a3b8ff99b54679f2a1b5da7f8cf52992adb34840
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-24 20:06:16 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-08-16 02:41:34 +0000

    procdesc: Remove dead code
    
    (cherry picked from commit 9a7bd3309bec08802e8c18c03669812ec3352534)
---
 sys/kern/kern_exit.c    |  3 ++-
 sys/kern/sys_procdesc.c | 22 ++++------------------
 sys/sys/procdesc.h      |  2 +-
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index eac381f90152..7fb3f115af9d 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -683,7 +683,8 @@ exit1(struct thread *td, int rval, int signo)
 	 * exit().
 	 */
 	signal_parent = 0;
-	if (p->p_procdesc == NULL || procdesc_exit(p)) {
+	procdesc_exit(p);
+	if (p->p_procdesc == NULL) {
 		/*
 		 * Notify parent that we're gone.  If parent has the
 		 * PS_NOCLDWAIT flag set, or if the handler is set to SIG_IGN,
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index 9b007aa8997b..608771b9f38c 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -278,45 +278,31 @@ procdesc_free(struct procdesc *pd)
  * We use the proctree_lock to ensure that process exit either happens
  * strictly before or strictly after a concurrent call to procdesc_close().
  */
-bool
+void
 procdesc_exit(struct proc *p)
 {
 	struct procdesc *pd;
 
 	sx_assert(&proctree_lock, SA_XLOCKED);
 	PROC_LOCK_ASSERT(p, MA_OWNED);
-	KASSERT(p->p_procdesc != NULL, ("procdesc_exit: p_procdesc NULL"));
 	MPASS((p->p_flag & P_WEXIT) != 0);
 
 	pd = p->p_procdesc;
+	if (pd == NULL)
+		return;
 
 	PROCDESC_LOCK(pd);
-	KASSERT(pd->pd_fpcount > 0 || p->p_pptr == p->p_reaper,
-	    ("procdesc_exit: closed && parent not reaper"));
+	KASSERT(pd->pd_fpcount > 0, ("%s: closed procdesc %p", __func__, pd));
 
 	pd->pd_flags |= PDF_EXITED;
 	pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig);
 
-	/*
-	 * If the process descriptor has been closed, then we have nothing
-	 * to do; return 1 so that init will get SIGCHLD and do the reaping.
-	 * Clean up the procdesc now rather than letting it happen during
-	 * that reap.
-	 */
-	if (pd->pd_fpcount == 0) {
-		PROCDESC_UNLOCK(pd);
-		pd->pd_proc = NULL;
-		p->p_procdesc = NULL;
-		procdesc_free(pd);
-		return (true);
-	}
 	selwakeup(&pd->pd_selinfo);
 	KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT | NOTE_PDSIGCHLD);
 	PROCDESC_UNLOCK(pd);
 
 	/* Wakeup all waiters for this procdesc' process exit. */
 	wakeup(&p->p_procdesc);
-	return (false);
 }
 
 void
diff --git a/sys/sys/procdesc.h b/sys/sys/procdesc.h
index ac23dbdcb53b..bb486d9026ba 100644
--- a/sys/sys/procdesc.h
+++ b/sys/sys/procdesc.h
@@ -102,7 +102,7 @@ struct procdesc {
 /*
  * In-kernel interfaces to process descriptors.
  */
-bool	 procdesc_exit(struct proc *);
+void	 procdesc_exit(struct proc *);
 void	 procdesc_fork(struct proc *p, pid_t child_pid);
 void	 procdesc_jobstate(struct proc *p);
 int	 kern_pdgetpid(struct thread *, int fd, const cap_rights_t *,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.