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