bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improved tail patch


From: tigger
Subject: Re: Improved tail patch
Date: Wed, 21 Jul 2004 20:36:25 +0000
User-agent: Mutt/1.5.6i

On Wed, Jul 21, 2004 at 11:54:35AM -0700, Paul Eggert wrote:
> Also, how about this small patch to fix your immediate problem?  It
> doesn't fix the general case, but it does fix a POSIX-conformance bug
> and it fixes your test example.  (It's weird that "tail -f" and "tail
> -f -" have different behavior when standard input is a pipe, but
> that's what POSIX explicitly requires....)

I should have been more specific regarding my problem :) The problem is
that if you do:

$ mkfifo /tmp/test.fifo
$ tail -f /tmp/test.fifo &
$ echo foo >> /tmp/test.fifo
$ echo foo >> /tmp/test.fifo

tail dies, and it shouldn't, and indeed none of the BSD tail
implementations I've been able to test do. Redhat's version of GNU tail
survives "echo foo | tail -f" but can't hack the fifo example I posted
above.

> Should we instead fix 'tail' to use select?  Surely that would be
> efficient (and easier) than all this stuff with O_NONBLOCK.
> (O_NONBLOCK gives me the willies.  :-)

Moving tail to use select won't help for fifo's I'm afraid. I think it
would also make keeping track of rotations and such messier, but I'm not
sure.

Select always returns ready for a fifo. As far as I know the only way to
know if there is anything to read on a fifo is to try it and see if you
get anything.

You could of course use things like feof and such, except that GNU tail
currently uses file-descriptor-based methods rather than stream based
ones, and feof only works on streams. So you'd need to re-write the lot.
And even then feof basically does a getc to check if it gets EOF I
beleive (could be wrong there).

Thanks for taking the time to look at my patch. I beleive it has to be
either this way (or a better coded version maybe?) or moving to a stream
based model and doing effectively the same thing.

I'm happy to discuss this via irc if you'd like.

Regards,

Rob

-- 
rob holland - [ address@hidden ]
[ 5251 4FAC D684 8845 5604  E44F D65C 392F D91B 4729 ]

Attachment: pgpZ7vdtY9Wtk.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]