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.
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)