Subject: bin/6176: tail -F is broken
To: None <gnats-bugs@gnats.netbsd.org>
From: Urban Boquist <boquist@cs.chalmers.se>
List: netbsd-bugs
Date: 09/18/1998 01:40:21
>Number: 6176
>Category: bin
>Synopsis: tail -F unnecessarily re-reads whole file
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 17 16:50:01 1998
>Last-Modified:
>Originator: Urban Boquist
>Organization:
Dept. of CS, Chalmers, Sweden
>Release: NetBSD-current
>Environment:
System: NetBSD beavis 1.3H NetBSD 1.3H (BEAVIS) #0: Wed Sep 9 20:21:31 CEST 1998 root@beavis:/usr/src/sys/arch/i386/compile/BEAVIS i386
>Description:
tail -F will stat(2) the file every 5 seconds to see if it has shrunk. This
works, mostly, but there is a spurious "lastsize++" that makes the logic
fail sometimes. It fails because lastsize is initialised from the stat call
and then incremented for each character read, but there is nothing saying
that the number of characters read is the same as the file size from stat.
Removing the increment makes it work as it should, and I can't see anything
else that would break.
>How-To-Repeat:
Run tail -F on a file that is constantly growing. Watch it re-read the
whole file occasionally (depending on how fast the file grows).
>Fix:
Apply the following in src/usr.bin/tail/.
--- forward.c.orig Fri Feb 20 13:17:10 1998
+++ forward.c Fri Sep 18 01:10:06 1998
@@ -176,7 +176,6 @@
for (;;) {
while ((ch = getc(fp)) != EOF) {
- lastsize++; /* track size changes between stats */
if (putchar(ch) == EOF)
oerr();
}
>Audit-Trail:
>Unformatted: