X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0	tests=AWL,BAYES_00,KHOP_THREADED,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4FAC9E98.2040908@tlinx.org>
Date: Thu, 10 May 2012 22:07:36 -0700
From: Linda Walsh <cygwin@tlinx.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: Cygwin passes through null writes to other software when redirecting standard input/output (i.e. piping)
References: <020501cd23f2$20f07620$62d16260$@motionview3d.com> <20120427143753.GO25385@calimero.vinschen.de> <025501cd24c6$6a353990$3e9facb0$@motionview3d.com> <4F9B38FB.9030607@dancol.org> <20120428052727.GA23749@ednor.casa.cgf.cx> <4F9BD262.2000403@dancol.org> <4FAABEAE.7000309@tlinx.org> <053b01cd2e18$f3f9ce60$dbed6b20$@motionview3d.com>
In-Reply-To: <053b01cd2e18$f3f9ce60$dbed6b20$@motionview3d.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

James Johnston wrote:


>> I can't say with 100% certainty, but I would bet with 90+% confidence that
>> this
>> is a bug in MS's libraries -- they "cheat" and use a null/0 byte read as a
>> signal for end of file rather than sending out-of-band information that *nix
>> supports.
> 
> From examining .NET Framework source, it seems clear to me they did not plan on message 

pipe inputs.  Win32 ReadFile API normally uses a zero byte read to indicate end-of-file; 

I think it's not cheating.  Pipes present a special case.  I'm not sure how MS's runtime 

libraries could send out-of-band information; the operating system does not really support

this as far as I know?

----
	It is cheating because they didn't follow the standard.  It is perfectly legal 
to write 0 bytes.


> 
> Of course, these libraries are very widely used... 

---
	MSWindows is widely used and is known to be one of the buggiest OS's on the 
planet.  So what's your point?


> 
>> Essentially you need a 'shim' layer between a POSIX compliant subsystem
>> to NON-POSIX compliant programs.
>>
>> I'm sure that in the case that my assumptions are true, you wouldn't want to
>> deliberate put something in cygwin that would make it less POSIX compliant
>> when
>> it is only to support external-to-cygwin, NON-POSIX compliant programs...
>>
>> Note -- I use programs between cygwin and Windows 'alot', so I want these
>> things
>> to work as well.
> 
> Maybe I'm naïve and this is harder than it looks, but couldn't Cygwin determine if 

the program being piped to links with CYGWIN1.DLL (or similar detection technique),

 and then use byte or message pipes accordingly?  Example:

---
	Because (1) it wouldn't be reliable.  2, cygwin could be delay-loaded so  again 
back to 1... and have you contacted Microsoft and asked them to fix the problem? 
   Who did you contact and what did they say?


> 
> # Byte pipe used because Win32Program.exe does not link with CYGWIN1.DLLL
> cat Testfile.txt | ./Win32Program.exe
> # Message pipe used because grep links with CYGWIN1.DLL
> cat Testfile.txt | grep Hello
> # Message pipe still used because the program we are calling links with CYGWIN1.DLL
> ./Win32Program.exe | grep Hello
> 
> If that is still not POSIX compliant enough for the sending program 

(e.g. "cat" in this example), then I suppose Cygwin could automatically insert a 

message-to-byte pipe shim like the author proposes.  That seems pretty kludgy though.

====
	Cygwin wouldn't insert a special shim for an app using a buggy library.  Or 
rather it wouldn't be the place of cygwin to do so.  It would be the 
responsibility of whoever needs to run some sort of adaptation with **THEIR** 
program... (and perhaps whoever they pay to do

I don't speak for the Cygwin project - the above is purely my point of view.

I was suggesting a way for you to create a workaround for your program


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

