git: cfb53f983f14 - stable/13 - ncal: Error out if writing to stdout failed.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Wed, 14 Jun 2023 13:26:28 UTC
The branch stable/13 has been updated by des:

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

commit cfb53f983f147a9c8388154a256c8b47be470f1b
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-06-14 12:42:28 +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
    
    (cherry picked from commit 5903d9c00b75f17f09404d1001ee5aaae7603a61)
---
 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 641c59f71e10..35266c225bce 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);
 }