On Wed, Sep 11, 2002 at 06:55:33PM +0300, Nadav Har'El wrote:
> On Wed, Sep 11, 2002, Muli Ben-Yehuda wrote about "tail(1) and char device files":
> > Perusing the tail source code shows that for files which are not
> > regular files, tail just hordes up all output, until it runs out of
> > memory or EOF is reached and only then it prints it. Does anyone know
> > why it behaves this way for character device files and pipes? 
> 
> How would you want "tail" to behave?
> 
> Imagine you have a non-seekable file, but still a file that eventually
> will end with an EOF (imagine, even, running tail without parameters and
> it will be waiting for user input). Now, tail is suppose, when it ends
> to print the last 10 lines (for example). How can it do that without
> actually reading the entire input, always keeping the last 10 lines in
> memory? There is no need to keep the entire input in memory, though -
> only the last 10 lines read must be in memory at all times.

You are basically right, except that I've been testing with '-f', so I
expect it to show me the last ten lines of what it read right now, and
then continue printing everything. 

Interestingly, -f is ignored on non regular files. The man page
doesn't say it, but the info page does. 

> You're probably not interested in "tail"ing a non-seekable file, but rather
> in "tail -f"ing it. In that case, forget about tail - use cat instead
> (if you're looking for a "cat" that lseeks to the end of file first - well,
> that's not what tail does...).

That's what we've been doing, naturally. But if I made the mistake of
expecting 'tail -f' to work, I'm sure my users will too. Oh well, we
needed an FAQ anyway :) 

Thanks for your explanations. You prove once again that your advogao
Master rating is warranted ;) 
-- 
Muli Ben-Yehuda
syscalltrack hacker-at-large

Attachment: msg21699/pgp00000.pgp
Description: PGP signature

Reply via email to