The branch main has been updated by allanjude:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=63f5c101a1fdf4e8b94c5d76afcd6cbf0b2c79da

commit 63f5c101a1fdf4e8b94c5d76afcd6cbf0b2c79da
Author:     Cosimo Cecchi <[email protected]>
AuthorDate: 2024-06-06 16:51:22 +0000
Commit:     Allan Jude <[email protected]>
CommitDate: 2024-06-06 17:04:37 +0000

    comm: flush stdout for error checking prior to exiting
    
    UNIX conformance wants utilities to catch any errors when doing I/O, as
    opposed to relying on the implicit flush upon exit.
    comm currently does not do that.
    This commit adds handling of I/O errors on stdout prior to exit.
    
    Reviewed by:    imp, allanjude
    Sponsored by:   Apple Inc.
    Differential Revision:  https://reviews.freebsd.org/D45439
---
 usr.bin/comm/comm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.bin/comm/comm.c b/usr.bin/comm/comm.c
index b8fb10ccddb4..2f305e23ce8f 100644
--- a/usr.bin/comm/comm.c
+++ b/usr.bin/comm/comm.c
@@ -172,6 +172,8 @@ main(int argc, char *argv[])
                                (void)printf("%s%s\n", col2, line2);
                }
        }
+       if (ferror(stdout) != 0 || fflush(stdout) != 0)
+               err(1, "stdout");
        exit(0);
 }
 

Reply via email to