HomeFreeBSD

diff: Fix pagination leak

Description

diff: Fix pagination leak

  • Drop an unnecessary variable and rename pidfd to procd.
  • Rewinding stdout serves no purpose, so stop doing it.
  • Don't bother freeing memory or setting the global status right before erroring out.
  • Error out if dup(2) or dup2(2) fail.
  • In the unlikely case that our pipe is equal to stdout, we need to record that information so we don't close it when cleaning up.
  • Don't bother closing a descriptor before dup2(2)ing to it.
  • Don't forget to close the the process descriptor after reaping the child process.

Approved by: re (cperciva)
PR: 266592
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, markj
Differential Revision: https://reviews.freebsd.org/D55112

(cherry picked from commit c3904a7de78ca1ca15fcdf4c09f9d4be7f6fe6f5)
(cherry picked from commit 144455c333dc0d3db369596038de2e3dd6113b46)

Details

Provenance
desAuthored on Feb 5 2026, 2:39 PM
cpercivaCommitted on Feb 11 2026, 6:14 AM
Reviewer
kevans
Differential Revision
D55112: diff: Fix pagination leak
Parents
rG2434f3b279a9: diff: Add test case for pagination resource leak
Branches
Unknown
Tags
Unknown