Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 57477 - Fix for broken tail -f behaviour when watching fifos
Summary: Fix for broken tail -f behaviour when watching fifos
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All All
: High normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-18 06:34 UTC by rob holland (RETIRED)
Modified: 2005-01-07 21:26 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fix lseek on fifo bug (tail.patch,390 bytes, patch)
2004-07-18 06:34 UTC, rob holland (RETIRED)
Details | Diff
improved patch for tail (tail.patch,4.87 KB, patch)
2004-07-19 09:16 UTC, rob holland (RETIRED)
Details | Diff
patch to fix tail (coreutils.tail.patch,22.60 KB, patch)
2005-01-07 02:05 UTC, rob holland (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rob holland (RETIRED) gentoo-dev 2004-07-18 06:34:37 UTC
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 rob holland (RETIRED) gentoo-dev 2004-07-18 06:34:59 UTC
Created attachment 35692 [details, diff]
fix lseek on fifo bug
Comment 2 rob holland (RETIRED) gentoo-dev 2004-07-19 01:26:07 UTC
Please hold off on this for a bit. This patch causes high cpu usage. I'll work on a better fix.
Comment 3 rob holland (RETIRED) gentoo-dev 2004-07-19 09:16:42 UTC
Created attachment 35751 [details, diff]
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 rob holland (RETIRED) gentoo-dev 2004-07-24 07:11:20 UTC
upstream have commited a patch that fixes this problem.
Comment 5 rob holland (RETIRED) gentoo-dev 2005-01-07 02:05:05 UTC
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 rob holland (RETIRED) gentoo-dev 2005-01-07 02:05:43 UTC
Created attachment 47820 [details, diff]
patch to fix tail
Comment 7 SpanKY gentoo-dev 2005-01-07 21:26:50 UTC
will be fixed in 5.2.1-r4, thanks