[BusyBox] Re: tail patch

Matt Kraai kraai at alumni.cmu.edu
Thu Aug 8 08:51:03 UTC 2002


On Thu, Aug 08, 2002 at 04:46:58PM +0200, Matthias Lang wrote:
> Matt Kraai writes:
>  > On Thu, Aug 08, 2002 at 11:14:14AM +0200, Matthias Lang wrote:
>  > > The appended patch against 0.60.3 provides a quick fix.
>  > 
>  > I'd suggest decrementing nfiles if a file cannot be opened, and
>  > then checking that nfiles is not equal to zero.
> 
> Tail expects the array of filesdescriptors to correspond to the names
> in argv. If you mess with nfiles you would also have to mess around
> with the strings in argv. Example:
> 
>   tail real_file1 bogus_file real_file2
> 
> would print
> 
>   ==> real_file1 <==
>   (contents of that real_file1)
>   ==> bogus_file <==
>   (contents of that real_file2)
> 
> which is wrong. 
> 
> Other alternatives I considered and discarded were:
> 
>   - (ab)using 'seen' (fails on growing files) 
>   
>   - having a "at least one filedescriptor was non-negative"
>     flag in the while(follow) {...} loop (causes an unwanted sleep) 
> 
>   - re-shuffling argv[] (was more complicated than counting duds)
> 
> I settled on the counting duds because it was "obviously correct".

OK with me then.

Matt



More information about the busybox mailing list