diff options
author | Vincent Lefevre <vincent@vinc17.net> | 2021-06-30 13:50:23 +0200 |
---|---|---|
committer | Vincent Lefevre <vincent@vinc17.net> | 2021-06-30 13:50:23 +0200 |
commit | 768ba86a01fbe23bfcbbd3bc9db4b6ee361a0398 (patch) | |
tree | 152ade357fb9ea1f5c655f8eddf018685f2aede2 /main.c | |
parent | e6bcc2deeea847a3b662707afb05e1ec9e6eaee1 (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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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); } |