Part of the accepted-design index.
The usage guide owns acquisition, signaling, reaping, and file duplication workflows. Verification records runtime evidence.
Go already uses pidfds for os.Process. OpenProcess duplicates the stable handle inside Process.WithHandle; looking up Process.Pid again would reintroduce a PID-reuse window. The duplicate gives independent local ownership while preserving the original process manager’s reaping responsibility. Numeric Open remains useful when no stable handle exists, but cannot establish identity before acquisition.
Adopt consumes the input on both success and failure, eliminating conditional caller cleanup. Validation uses pidfs identity and descriptor flags rather than signal zero: signal permission is unrelated to descriptor type, and an already reaped handle is still a valid pidfd. Thread handles and path-only descriptors are excluded because they do not provide the promised process operations. See acquisition and validation.
A duplicate shares file status flags with its source. Requiring or enabling nonblocking mode for Go poller reads could interfere with os.Process waiting through another duplicate. The package instead polls the pidfd alongside a private eventfd, accepting either blocking mode without changing it. One extra descriptor and explicit closed state are the cost of safe standard-library composition and close interruption.
The wake record stays unread so every pending waiter observes shutdown. Protected file references prevent descriptor reuse while polling. This avoids a background event loop or cancellation goroutine, but each blocked waiter can occupy an OS thread. Contexts, deadlines, and wait-many orchestration are omitted rather than promised without another interruption model.
Readiness can be observed repeatedly; child status can be consumed only once. Wait combines readiness with nonblocking waitid checks so non-children fail promptly and competing reapers retain Linux’s ECHILD behavior. Caching an Exit would hide whether this call actually reaped the child. Close releases handles without killing or reaping.
The private SIGCHLD decoder is shared with the process wait-any path. It reads the maintained x/sys siginfo storage using the supported amd64/arm64 ABI, without depending on Go’s private process structures. CoreDump preserves CLD_DUMPED rather than inferring it from a signal or promising that a core file exists.
Go’s stable handle contract and Linux 7.0 pidfs underpin the ownership and identity choices.
DuplicateFile borrows the live pidfd through its existing close-safe control operation. The x/sys binding obtains a close-on-exec descriptor atomically, and os.NewFile takes ownership without changing the description’s blocking mode. Using the kernel duplication operation preserves the current file offset, status flags, and ptrace/LSM checks that a procfs reopen would lose. The target file number identifies a slot in the target’s current table, so callers coordinate reuse separately from process identity. Linux 7.0 pidfd_getfd implementation.