[BusyBox] tail: dprintf [PATCH]
Shaun Jackman
sjackman at gmail.com
Wed Apr 6 18:25:02 UTC 2005
tail uses the non-portable dprintf to test for an output error. A
portable alternative is to check the return values of printf and
flush. In this case where a stream is readily available for the file
descriptor, I prefer this patch, but an alternative is to provide an
implementation of dprintf in libbb as is already done for vdprintf.
Cheers,
Shaun
2005-04-06 Shaun Jackman <sjackman at gmail.com>
* coreutils/tail.c (tail_xprint_header): Use printf and fflush
instead of the non-portable dprintf.
Index: coreutils/tail.c
===================================================================
--- coreutils/tail.c (revision 10071)
+++ coreutils/tail.c (working copy)
@@ -62,7 +62,8 @@
static void tail_xprint_header(const char *fmt, const char *filename)
{
/* If we get an output error, there is really no sense in continuing. */
- if (dprintf(STDOUT_FILENO, fmt, filename) < 0) {
+ if (printf(fmt, filename) < 0 ||
+ fflush(stdout) < 0) {
bb_perror_nomsg_and_die();
}
}
More information about the busybox
mailing list