Bug 57477 - Fix for broken tail -f behaviour when watching fifos
Bug#: 57477 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: All Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: base-system@gentoo.org Reported By: tigger@gentoo.org
Component: Core system
URL: 
Summary: Fix for broken tail -f behaviour when watching fifos
Keywords:  
Status Whiteboard: 
Opened: 2004-07-18 06:34 0000
Description:   Opened: 2004-07-18 06:34 0000
This small patch fixes tail -f to not do an lseek if the input is a fifo.

For example:

rob@localhost rob $ mkfifo /tmp/test.fifo
rob@localhost rob $ tail -f /tmp/test.fifo &
rob@localhost rob $ echo bah >> /tmp/test.fifo
bah
tail: /tmp/test.fifo: file truncated
tail: /tmp/test.fifo: cannot seek to offset 0: Illegal seek

The patch has been sent upstream but it would be nice if this could be patched in the ebuild until it has been accepted by the coreutils maintainers.

------- Comment #1 From rob holland (RETIRED) 2004-07-18 06:34:59 0000 -------
Created an attachment (id=35692) [details]
fix lseek on fifo bug

------- Comment #2 From rob holland (RETIRED) 2004-07-19 01:26:07 0000 -------
Please hold off on this for a bit. This patch causes high cpu usage. I'll work
on a better fix.

------- Comment #3 From rob holland (RETIRED) 2004-07-19 09:16:42 0000 -------
Created an attachment (id=35751) [details]
improved patch for tail

This fixes the CPU issues with the former patch.

FIFOs are no longer stat'd in the tail_forever loop.

If data is read from one or more FIFOs during a tail_forever loop then all
FIFOs are skipped the next time around the loop. This prevents the case where
two FIFOs had opposite read_eof flags causing tail to loop forever checking and
flipping the flags without sleeping.

------- Comment #4 From rob holland (RETIRED) 2004-07-24 07:11:20 0000 -------
upstream have commited a patch that fixes this problem.

------- Comment #5 From rob holland (RETIRED) 2005-01-07 02:05:05 0000 -------
upstream still haven't released the flippin thing though.

"ported" patch to sys-apps/coreutils is attached.

Please commit.

You can test by merging the -r4 ebuild and trying:

echo foo | tail -f

It should not die with an illegal seek error message.

------- Comment #6 From rob holland (RETIRED) 2005-01-07 02:05:43 0000 -------
Created an attachment (id=47820) [details]
patch to fix tail

------- Comment #7 From SpanKY 2005-01-07 21:26:50 0000 -------
will be fixed in 5.2.1-r4, thanks