aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 80a66fbf5..49f1bcd6a 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -42,20 +42,25 @@ static const struct suffix_mult tail_suffixes[] = {
42 42
43static int status; 43static int status;
44 44
45static void tail_xprint_header(const char *fmt, const char *filename) 45static void tail_xbb_full_write(const char *buf, size_t len)
46{ 46{
47 /* If we get an output error, there is really no sense in continuing. */ 47 /* If we get a write error, there is really no sense in continuing. */
48 if (dprintf(STDOUT_FILENO, fmt, filename) < 0) { 48 if (full_write(STDOUT_FILENO, buf, len) < 0)
49 bb_perror_nomsg_and_die(); 49 bb_perror_nomsg_and_die();
50 }
51} 50}
52 51
53/* len should probably be size_t */ 52static void tail_xprint_header(const char *fmt, const char *filename)
54static void tail_xbb_full_write(const char *buf, size_t len)
55{ 53{
56 /* If we get a write error, there is really no sense in continuing. */ 54#if defined __GLIBC__
57 if (full_write(STDOUT_FILENO, buf, len) < 0) 55 if (dprintf(STDOUT_FILENO, fmt, filename) < 0) {
58 bb_perror_nomsg_and_die(); 56 bb_perror_nomsg_and_die();
57 }
58#else
59 int hdr_len = strlen(fmt) + strlen(filename);
60 char *hdr = xzalloc(hdr_len);
61 sprintf(hdr, filename, filename);
62 tail_xbb_full_write(hdr, hdr_len);
63#endif
59} 64}
60 65
61static ssize_t tail_read(int fd, char *buf, size_t count) 66static ssize_t tail_read(int fd, char *buf, size_t count)