Tail not reading to end of input

smr xxxx smrxxxx@gmail.com
Tue Apr 15 23:53:00 GMT 2008


I've done some debugging of tail.exe on XP (which works) and Vista
Enterprise SP1 (which doesn't), and so far have found two differences
when tailing output piped from another program:
  1. S_ISREG (stats.st_mode) returns 0 on XP, but 1 on Vista (I
haven't yet determined if this is an Enterprise-only or an SP1-only
issue)
  2. lseek() fails on XP, but succeeds on Vista.  The SEEK_CUR below
returns 0, and the SEEK_END consistently returns 4105 in my tests (for
output that should be much longer, so presumably it's looking at a
single buffer of data).
Combines, this means that on XP the following code in tail.c results
in pipe_lines being called (as expected), but on Vista file_lines is
being called.  Does any of this mean anything to anyone?

      /* Use file_lines only if FD refers to a regular file for
	 which lseek (... SEEK_END) works.  */
      if ( ! presume_input_pipe
	   && S_ISREG (stats.st_mode)
	   && (start_pos = lseek (fd, 0, SEEK_CUR)) != -1
	   && start_pos < (end_pos = lseek (fd, 0, SEEK_END)))
	{
                          file_lines(...);
                }
                else
                {
                          pipe_line(...);
                }


On Mon, Apr 14, 2008 at 10:56 AM, smr xxxx <smrxxxx@gmail.com> wrote:
> Hi, I've just rebuilt my machine and done a clean install of the
> latest Cygwin, and am having a problem with tail.  I'm wanting to know
> whether this is a known issue before digging deeper.  For other
> reasons, I've rebuilt my machine clean twice this weekend and have had
> this problem both times -- I also sourced the Cygwin files from two
> different mirrors.
>
> It's been a few months since I last installed Cygwin, and all I can
> think of that has changed since then is:
>  1. I have a newer version of Cygwin
>  2. I'm now on Vista Enterprise (was Vista Ultimate)
>  3. I'm now on an SP1 of Vista (was original RTM of Vista)
>
> When running a command such as "dir /s /a cygwin | tail -2" (from C:\)
> it displays:
>  03/04/2008  10:32 PM                35 7zr
>  07/19/2007  02:05 PM
> This last line is the 29th line of output.  Redirecting to a file
> shows that there are 7 spaces at the end of this last line, and the
> total output is 1028 bytes, or 1000 after running dos2unix.
>
> Moving C:\cygwin to C:\x\cygwin (to force some extra characters into
> the output of the above command, ie. the "x\") and rerunning shows
> that it again stops at precisely the same place (7 spaces after the
> time on the 29th line), but the output is now 1032 bytes, or 1004
> after running dos2unix, due to the extra characters.
>
> If I first redirect the output of the dir command to a file and tail
> that then all is well.  Even running "type filename | tail -2" works.
> Also, if I dos2unix the stream inplace (ie. "dir /s /a cygwin |
> dos2unix | tail -2") it works correctly.  Note that I installed with
> Unix file type (as always).
>
> I just tried the same on \Windows, and it stops on the 26th line at a
> position that seems to amount to 1124 bytes, or 1098 when dos2unix'd.
>
> I'm guessing that this is a bigger problem that just tail (I could be
> wrong), but "dir /s /a cygwin | wc -l" doesn't have any problems.
>
> Has anyone seen this before?
>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list