Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Jan 2026 20:10:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 292255] pdgetpid wrongly succeeds for processes that have already been waited
Message-ID:  <bug-292255-227@https.bugs.freebsd.org/bugzilla/>

index | next in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292255

            Bug ID: 292255
           Summary: pdgetpid wrongly succeeds for processes that have
                    already been waited
           Product: Base System
           Version: 16.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: asomers@FreeBSD.org

pdgetpid(2) can lookup the pid corresponding to a particular process
descriptor.  A common use case is to wait on a child, since there is no such
thing as pdwait4().

When using a function like waitpid(pid, ..., WEXITED), it is very important not
to call it twice for the same pid.  Doing so could lead to inadvertently
waiting on an unrelated process after the desired process has exited.

In its current form, pdgetpid() will still return the original pid, even after
the child has died and been waited upon.  That's a bug, IMHO, because it can
lead to users calling waitpid() on the same pid twice.

IMHO, pdgetpid should return ESRCH in this case.

See the attached file for an ATF test case that demonstrates the problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-292255-227>