From hburch@lumeta.com  Fri Jun 13 12:09:14 2003
Return-Path: <hburch@lumeta.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0966437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jun 2003 12:09:14 -0700 (PDT)
Received: from exgw2.lumeta.com (exgw2.lumeta.com [65.198.68.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1083943FCB
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jun 2003 12:09:13 -0700 (PDT)
	(envelope-from hburch@lumeta.com)
Received: from lucy.corp.lumeta.com (h65-246-245-10.lumeta.com [65.246.245.10])
	by exgw2.lumeta.com (Postfix) with ESMTP id 8ACC837383D
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jun 2003 15:09:12 -0400 (EDT)
Received: from localhost (localhost.corp.lumeta.com [127.0.0.1])
	by lucy.corp.lumeta.com (Postfix) with ESMTP id 5BBA4A896A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jun 2003 15:09:12 -0400 (EDT)
Received: from lucy.corp.lumeta.com ([127.0.0.1])
 by localhost (lucy.corp.lumeta.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 18619-04 for <FreeBSD-gnats-submit@freebsd.org>;
 Fri, 13 Jun 2003 15:09:12 -0400 (EDT)
Received: from hburch.corp.lumeta.com (hburch.corp.lumeta.com [65.246.246.59])
	by lucy.corp.lumeta.com (Postfix) with ESMTP id 0363DA8968
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jun 2003 15:09:12 -0400 (EDT)
Received: by hburch.corp.lumeta.com (Postfix, from userid 2007)
	id 1EDE35E3; Fri, 13 Jun 2003 15:09:09 -0400 (EDT)
Message-Id: <20030613190909.1EDE35E3@hburch.corp.lumeta.com>
Date: Fri, 13 Jun 2003 15:09:09 -0400 (EDT)
From: Hal Burch <hburch@lumeta.com>
Reply-To: Hal Burch <hburch@lumeta.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: tail will sometimes display more lines than it is told
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         53288
>Category:       bin
>Synopsis:       tail(1) will sometimes display more lines than it is told
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    edwin
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 13 12:10:14 PDT 2003
>Closed-Date:    
>Last-Modified:  Mon Aug 04 12:08:21 UTC 2008
>Originator:     Hal Burch
>Release:        FreeBSD 4.8-RC i386
>Organization:
Lumeta Comporation
>Environment:
System: FreeBSD hburch.corp.lumeta.com 4.8-RC FreeBSD 4.8-RC #1: Wed Mar 26 17:25:56 EST 2003 root@hburch.corp.lumeta.com:/usr/obj/usr/src/sys/LOCAL i386
>Description:
tail will sometimes output more lines than it is told if the file is
being appended to.  I believe this is occurs when data is written
to the file after tail computes where to start displaying data,
but before the display starts.
>How-To-Repeat:
Run one program that continuously prints out lines to a file:
	while [ 1 ]; do echo test; done > file
While that is running, run a bunch of tails and compute their length
	for i in `seq 1 1000`; do tail file | wc -l | done > linecnt
(In case it's not clear from the name, seq prints out 1 through 1000)
Look at the distribution of the line counts that were displayed:
 	sort -n linecnt | uniq -c

On my run:
 975       10
   1       61
   1       68
   1      118
   1      131
   1      134
   2      138
   1      168
   2      170
   1      174
   1      205
   1      227
   1      235
   1      259
   1      291
   1      348
   1      362
   1      367
   1      797
   1     1170
   1     1562
   1     2198
   1     5738
   1     5861
>Fix:
No known fix.  tail could declare the end of the file (when -f is not
done) to be the length of the file when it first touches it, but that
could cause additional problems.
>Release-Note:
>Audit-Trail:

From: Friedemann Becker <Friedemann.Becker@student.uni-tuebingen.de>
To: freebsd-gnats-submit@FreeBSD.org, hburch@lumeta.com
Cc:  
Subject: Re: bin/53288: tail will sometimes display more lines than it is
 told
Date: Thu, 25 Dec 2003 20:48:03 +0100

 in How-To-Repeat it should be
 
 while [ 1 ]; do echo test; done > file
 
 and
 
 for i in `jot 1000 1`; do tail file | wc -l; done > linecnt
 
 
 (
  - freebsd uses jot, seq is gnu and if you install it via the port 
 /usr/ports/misc/sh-utils you have to invoke it with 'gseq'
  - semikolon before done
 )
 
 
 I have got an easy workaround for it:
 
 if a file is written to (or could be) while you want to 'tail' it, just 
 do an
 cat file | tail
 that gives tail a snapshot of the file and the results of the above test 
 are correct.
 
 but someone should document this in man1/tail.1
 
 

From: Friedemann Becker <Friedemann.Becker@web.de>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/53288: tail will sometimes display more lines than it is
 told
Date: Wed, 14 Jan 2004 13:11:56 +0100

 This is a multi-part message in MIME format.
 --------------050206010607070606030305
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 I wrote this little note for the tail.1 manpage.
 I am still new to this and I'm not sure, if this should be mentioned in
 the manpage or not.
 If the text is ok, please someone proofread and maybe commit it.
 Otherwise, some commentary would be nice.
 thanks
 
 
 
 
 --------------050206010607070606030305
 Content-Type: text/plain;
  name="tail.1"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="tail.1"
 
 --- tail.1.orig	Tue Jan 13 00:18:41 2004
 +++ tail.1	Tue Jan 13 00:50:54 2004
 @@ -181,3 +181,22 @@
  A
  .Nm
  command appeared in PWB UNIX.
 +.Sh BUGS
 +When
 +.Nm
 +is used on a file that is being written to, the number of lines (bytes
 +or blocks, respectively) of the output can be significantly different
 +from what has been specified by the
 +.Fl n ,
 +.Fl c
 +or
 +.Fl b
 +option. This happens when data is is beeing appended to the file
 +after
 +.Nm
 +has calculated the starting point for the output.
 +
 +To avoid this send the data through a pipe, as in
 +.Dl "cat growing_file | tail -n 20"
 +.Pp
 +This should give correct results.
 
 
 
 --------------050206010607070606030305--
 

From: Friedemann Becker <Friedemann.Becker@web.de>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/53288: tail will sometimes display more lines than it is
 told
Date: Wed, 14 Jan 2004 13:19:45 +0100

 This is a multi-part message in MIME format.
 --------------080400060907090409020109
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 I wrote this little note for the tail.1 manpage.
 I am still new to this and I'm not sure, if this should be mentioned in
 the manpage or not.
 If the text is ok, please someone proofread and maybe commit it.
 Otherwise, some commentary would be nice.
 thanks
 
 
 
 
 --------------080400060907090409020109
 Content-Type: text/plain;
  name="tail.1"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="tail.1"
 
 --- tail.1.orig	Tue Jan 13 00:18:41 2004
 +++ tail.1	Tue Jan 13 00:50:54 2004
 @@ -181,3 +181,22 @@
  A
  .Nm
  command appeared in PWB UNIX.
 +.Sh BUGS
 +When
 +.Nm
 +is used on a file that is being written to, the number of lines (bytes
 +or blocks, respectively) of the output can be significantly different
 +from what has been specified by the
 +.Fl n ,
 +.Fl c
 +or
 +.Fl b
 +option. This happens when data is is beeing appended to the file
 +after
 +.Nm
 +has calculated the starting point for the output.
 +
 +To avoid this send the data through a pipe, as in
 +.Dl "cat growing_file | tail -n 20"
 +.Pp
 +This should give correct results.
 
 
 
 --------------080400060907090409020109--
 
Responsible-Changed-From-To: freebsd-bugs->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Aug 4 12:07:55 UTC 2008 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=53288 
>Unformatted:
