The branch main has been updated by jilles:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8bf4902569869133affd91bdcb71b74656cfc36e

commit 8bf4902569869133affd91bdcb71b74656cfc36e
Author:     Jilles Tjoelker <[email protected]>
AuthorDate: 2026-06-03 20:42:01 +0000
Commit:     Jilles Tjoelker <[email protected]>
CommitDate: 2026-06-03 20:50:38 +0000

    diff: Correct fd 0 case on pipe
    
    After git commit c8d40bf8ecc60cc15e3904410db62065ea681fdc, if fd 0 was
    not open, it is left with CLOEXEC set and therefore fails. This is an
    unlikely situation, but fixing it reduces the size of the code (by using
    posix_spawn_file_actions_adddup2's special case if the two file
    descriptor numbers are the same).
    
    At the same time, check the error code from
    posix_spawn_file_actions_adddup2.
    
    Reviewed by:    bapt
    Differential Revision:  https://reviews.freebsd.org/D56910
---
 usr.bin/diff/pr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr.bin/diff/pr.c b/usr.bin/diff/pr.c
index e8a4162d8b18..57cbb6a56ce5 100644
--- a/usr.bin/diff/pr.c
+++ b/usr.bin/diff/pr.c
@@ -71,8 +71,9 @@ start_pr(char *file1, char *file2)
 
        posix_spawnattr_setprocdescp_np(&sa, &pr->procd, 0);
 
-       if (pfd[0] != STDIN_FILENO)
-               posix_spawn_file_actions_adddup2(&fa, pfd[0], STDIN_FILENO);
+       error = posix_spawn_file_actions_adddup2(&fa, pfd[0], STDIN_FILENO);
+       if (error != 0)
+               errc(2, error, "posix_spawn_file_actions_adddup2");
 
        char *argv[] = { __DECONST(char *, _PATH_PR),
            __DECONST(char *, "-h"), header, NULL };

Reply via email to