bin/54492: tail -F duplicates lines

Colin Percival cperciva at
Tue Jul 15 00:10:19 PDT 2003

>Number:         54492
>Category:       bin
>Synopsis:       tail -F duplicates lines
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 15 00:10:17 PDT 2003
>Originator:     Colin Percival
>Release:        FreeBSD 4.7-SECURITY
  tail -F sometimes duplicates lines after the first rotation.

cperciva at beastie$ rm foo && touch foo && ( for x in 1 2 3 4 5; do echo 
hello $x > foo && sleep 2 && echo world $x >> foo;done & tail -F foo )
hello 1
world 1
hello 2
hello 2		# this line shouldn't be here
world 2
hello 3
hello 3		# this line shouldn't be here
world 3
hello 4
hello 4		# this line shouldn't be here
world 4
hello 5
hello 5		# this line shouldn't be here
world 5

  I've also observed this when using `tail -F` on Apache logfiles (again, 
after the file has been rotated once; when that happens, it prints out 
all the lines in the file again, as if the file had been rotated).


  Based on the symptoms, I'd say it looks like a bug in either the 
rotation-detection or the truncation-detection code; but I'm not familiar 
enough with kqueue to say any more than that.

More information about the freebsd-bugs mailing list