summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorVincent Lefevre <vincent@vinc17.net>2021-06-30 13:50:23 +0200
committerVincent Lefevre <vincent@vinc17.net>2021-06-30 13:50:23 +0200
commit768ba86a01fbe23bfcbbd3bc9db4b6ee361a0398 (patch)
tree152ade357fb9ea1f5c655f8eddf018685f2aede2 /main.c
parente6bcc2deeea847a3b662707afb05e1ec9e6eaee1 (diff)
Fix usage and version write error checking.
"fflush (stdout)" is needed to detect most errors (only a closed stdout could be detected otherwise). A ferror test is also needed to avoid false positives since the C standard allows errno to be set even in the absence of errors.
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/main.c b/main.c
index 1f5f530b..b2e129c4 100644
--- a/main.c
+++ b/main.c
@@ -176,7 +176,9 @@ options:\n\
-Z\t\topen the first folder with new message, exit immediately if none\n\
-h\t\tthis help message");
- if (errno && errno != EPIPE)
+ fflush (stdout);
+
+ if (ferror (stdout) && errno && errno != EPIPE)
exit (1);
exit (0);
}
@@ -572,7 +574,9 @@ static void show_version (void)
mutt_print_patchlist();
- if (errno && errno != EPIPE)
+ fflush (stdout);
+
+ if (ferror (stdout) && errno && errno != EPIPE)
exit (1);
exit (0);
}