From: Jim Meyering Date: Thu, 17 Nov 1994 12:49:10 +0000 (+0000) Subject: (dump_remainder): Flush standard output just before X-Git-Tag: textutils-1_12_1~435 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53c46c67ac349397e57f5d50ae400531186a7a81;p=thirdparty%2Fcoreutils.git (dump_remainder): Flush standard output just before sleeping so that `tail -f' will output partial lines sooner. This applies only when following the end of a single file. From Leonard N. Zubkoff . (file_lines, pipe_lines, pipe_bytes, start_bytes, start_lines, dump_remainder): Use STDOUT_FILENO instead of `1' in XWRITE calls. --- diff --git a/src/tail.c b/src/tail.c index 770101b0c0..47d34f90e7 100644 --- a/src/tail.c +++ b/src/tail.c @@ -593,7 +593,7 @@ file_lines (filename, fd, number, pos) /* If this newline wasn't the last character in the buffer, print the text after it. */ if (i != bytes_read - 1) - XWRITE (1, &buffer[i + 1], bytes_read - (i + 1)); + XWRITE (STDOUT_FILENO, &buffer[i + 1], bytes_read - (i + 1)); return 0; } } @@ -724,10 +724,10 @@ pipe_lines (filename, fd, number) } else i = 0; - XWRITE (1, &tmp->buffer[i], tmp->nbytes - i); + XWRITE (STDOUT_FILENO, &tmp->buffer[i], tmp->nbytes - i); for (tmp = tmp->next; tmp; tmp = tmp->next) - XWRITE (1, tmp->buffer, tmp->nbytes); + XWRITE (STDOUT_FILENO, tmp->buffer, tmp->nbytes); free_lbuffers: while (first) @@ -821,10 +821,10 @@ pipe_bytes (filename, fd, number) i = total_bytes - number; else i = 0; - XWRITE (1, &tmp->buffer[i], tmp->nbytes - i); + XWRITE (STDOUT_FILENO, &tmp->buffer[i], tmp->nbytes - i); for (tmp = tmp->next; tmp; tmp = tmp->next) - XWRITE (1, tmp->buffer, tmp->nbytes); + XWRITE (STDOUT_FILENO, tmp->buffer, tmp->nbytes); free_cbuffers: while (first) @@ -857,7 +857,7 @@ start_bytes (filename, fd, number) return 1; } else if (number < 0) - XWRITE (1, &buffer[bytes_read + number], -number); + XWRITE (STDOUT_FILENO, &buffer[bytes_read + number], -number); return 0; } @@ -888,7 +888,10 @@ start_lines (filename, fd, number) return 1; } else if (bytes_to_skip < bytes_read) - XWRITE (1, &buffer[bytes_to_skip], bytes_read - bytes_to_skip); + { + XWRITE (STDOUT_FILENO, &buffer[bytes_to_skip], + bytes_read - bytes_to_skip); + } return 0; } @@ -909,13 +912,14 @@ dump_remainder (filename, fd) output: while ((bytes_read = safe_read (fd, buffer, BUFSIZ)) > 0) { - XWRITE (1, buffer, bytes_read); + XWRITE (STDOUT_FILENO, buffer, bytes_read); total += bytes_read; } if (bytes_read == -1) error (1, errno, "%s", filename); if (forever) { + fflush (stdout); sleep (1); goto output; }