cygwin fork()
Fri Sep 1 17:04:00 GMT 2006

On Fri, Sep 01, 2006 at 09:34:15AM -0700, wrote:
> BTW:
> I started up filemon to watch what was going on from it's standpoint, and it
> shows a huge number of READs on libtool, all SUCCESS, but the offset is always
> 1 higher than previous, with a length of 1. Like it's literally reading the file
> 1 byte at a time, then incrementing the offset - until it has fully been read.
> -cl

So right smack dab in the middle of _evalfile() under bash-3.1:

#if defined (__CYGWIN__) && defined (O_TEXT)
  setmode (fd, O_TEXT);

Also in read_comsub():

#ifdef __CYGWIN__
  setmode (fd, O_TEXT);         /* we don't want CR/LF, we want Unix-style */

And most importantly in open_shell_script():

  /* Open the script.  But try to move the file descriptor to a randomly
     large one, in the hopes that any descriptors used by the script will
     not match with ours. */
  fd = move_to_high_fd (fd, 0, -1);

#if defined (__CYGWIN__) && defined (O_TEXT)
  setmode (fd, O_TEXT);

The high fd part jives with the '255' seen in the readv() strace output as well.

This post from 2000 looks related:

In regards to setting the fd to textmode as a way of stripping CRs. Only problem
is that it's making 213,110 syscalls for a 213k libtool script. That cannot be an
efficient way to remove CRs from input.

Found the old references to that too:

#if 0
#if defined (__CYGWIN__)
      if (c == '\n' && istring_index > 1 && istring[istring_index - 2] == '\r')
          istring[istring_index - 1] = '\n';

I've since removed the setmode() calls within a bash build and am testing now.


Filemon now shows bash reading in 8k chunks. There is now no 3 second delay on
reading the rest of the bash script (which I evidenced earlier as well).

p.s. Seriously old stuff in there, for example:

#if defined (__CYGWIN__)
      /* Under CygWin 1.1.0, the unlink will fail if the file is
         open. This hack will allow the previous action of silently
         ignoring the error, but will still leave the file there. This
         needs some kind of magic. */
      if (r == EACCES)
        return (fd2);
#endif /* __CYGWIN__ */

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list