git: 5903d9c00b75 - main - ncal: Error out if writing to stdout failed.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 04 May 2023 18:52:51 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=5903d9c00b75f17f09404d1001ee5aaae7603a61

commit 5903d9c00b75f17f09404d1001ee5aaae7603a61
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-05-04 17:26:54 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-05-04 18:51:10 +0000

    ncal: Error out if writing to stdout failed.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    kevans, imp
    Differential Revision:  https://reviews.freebsd.org/D39958
---
 usr.bin/ncal/ncal.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c
index 5a6c33ce759d..b4f025141f92 100644
--- a/usr.bin/ncal/ncal.c
+++ b/usr.bin/ncal/ncal.c
@@ -497,6 +497,8 @@ main(int argc, char *argv[])
 			monthrangeb(y, m, flag_julian_day, before, after);
 		else
 			monthranger(y, m, flag_julian_day, before, after);
+	if (ferror(stdout) != 0 || fflush(stdout) != 0)
+		err(1, "stdout");
 	return (0);
 }