aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-05-26 12:25:47 -0500
committerRob Landley <rob@landley.net>2014-05-26 12:25:47 -0500
commitddbaa718dbe3370786eae97000f4c1e8bb259a61 (patch)
tree3ee130c5573a55bf386a6e0fe17e171c16f80c78 /lib
parent7cb7cca7f5759c6921d68a384fd838e01ce446e0 (diff)
downloadtoybox-ddbaa718dbe3370786eae97000f4c1e8bb259a61.tar.gz
Isaac Dunham suggested xprintf() should call fflush() instead of ferror(), and posix-2008 doesn't say if fflush() covers ferror() (or can return success when the stream's error state is set), so call both.
Diffstat (limited to 'lib')
-rw-r--r--lib/xwrap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 5310506c..69682f65 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -94,22 +94,23 @@ void xprintf(char *format, ...)
va_start(va, format);
vprintf(format, va);
- if (ferror(stdout)) perror_exit("write");
+ if (fflush(stdout) || ferror(stdout)) perror_exit("write");
}
void xputs(char *s)
{
- if (EOF == puts(s) || fflush(stdout)) perror_exit("write");
+ if (EOF == puts(s) || fflush(stdout) || ferror(stdout)) perror_exit("write");
}
void xputc(char c)
{
- if (EOF == fputc(c, stdout) || fflush(stdout)) perror_exit("write");
+ if (EOF == fputc(c, stdout) || fflush(stdout) || ferror(stdout))
+ perror_exit("write");
}
void xflush(void)
{
- if (fflush(stdout)) perror_exit("write");;
+ if (fflush(stdout) || ferror(stdout)) perror_exit("write");;
}
// Call xexec with a chunk of optargs, starting at skip. (You can't just