Subject: Re: GNU coreutils does not work on Cygwin because of freopen() ?
From: Ed Schouten <[email-masked]>
To: Sjors Gielen <[email-masked]>
Cc: "Yaakov (Cygwin/X)" <[email-masked]>, [email-masked], [email-masked]
Date: Sun, 18 Jan 2009 23:19:40 +0100
List-Id: <cygwin.cygwin.com>

Hello all,

* Sjors Gielen <[email-masked]> wrote:
> Yaakov (Cygwin/X) wrote:
>> Sjors Gielen wrote:
>>> Did you try with Cygwin coreutils or GNU coreutils? :)
>>
>> Cygwin's coreutils *is* GNU coreutils, with some patches which you will
>> find necessary.
>>
> [snip]
> Dave Korn wrote:
> >   However, you may have to recreate all the cygwin-specific patches
> > that the
> > cygwin bash maintainer hasn't managed to send upstream yet...
> [snip]
> > ?? Are you using an old version??  It should be fixed by now.
> >
> > http://www.mail-archive.com/[email-masked]/msg10188.html
>
> Oooh. Can I get a list of patches the Cygwin project has already applied  
> to packages? :)
> So this bug was fixed in Cygwin's version of GNU coreutils, but not in  
> Debian's version of GNU coreutils. Has a patch for that been sent  
> upstream? I took GNU coreutils from Debian sid, which should be almost  
> as up to date as it gets...

But that's not a proper fix anyway. cat can't just decide to reopen the
file descriptor of the standard output. That even breaks the first
sentence of POSIX:

	The cat utility shall read files in sequence and shall write
	their contents to the standard output in the same sequence.

If it says "the standard output" doesn't mean you can reopen the output
descriptor. This means you end up with two different file descriptors.
They can point to the same file, but they are not the same file
descriptor.

They fixed it by using SET_BINARY(), but not on Cygwin, because I assume
SET_BINARY() is a Windows-thing, not Cygwin.

I can't really understand why Cygwin just doesn't force O_BINARY to be
set. File descriptors on UNIX are supposed to display raw file contents.
There shouldn't be any (newline) processing. It makes no sense to
cripple Cygwin only because Notepad doesn't support newlines without the
carriage return.

-- 
 Ed Schouten <[email-masked]>
 WWW: http://80386.nl/