delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/05/09/15:00:25

X-Recipient: archive-cygwin AT delorie DOT 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: <4FAABEAE.7000309@tlinx.org>
Date: Wed, 09 May 2012 11:59:58 -0700
From: Linda Walsh <cygwin AT tlinx DOT 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 AT cygwin DOT com" <cygwin AT cygwin DOT 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 DOT GO25385 AT calimero DOT vinschen DOT de> <025501cd24c6$6a353990$3e9facb0$@motionview3d.com> <4F9B38FB DOT 9030607 AT dancol DOT org> <20120428052727 DOT GA23749 AT ednor DOT casa DOT cgf DOT cx> <4F9BD262 DOT 2000403 AT dancol DOT org>
In-Reply-To: <4F9BD262.2000403@dancol.org>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Daniel Colascione wrote:

> On 4/27/12 10:27 PM, Christopher Faylor wrote:
>> The above comment shows an "and" relationship here.  Message type pipes
>> more closely mimic Linux (UNIX) pipe behavior AND are definitely
>> required for ptys.
> 
> Yeah, but because message pipes break other programs. Cygwin has only
> been using message pipes since 23-Oct-11 (1.134), and it got along
> fine before that, ICANON aside. If Cygwin programs don't actually
> _need_ message pipes in the general case, Cygwin should use byte pipes
> instead.

----
But Daniel -- if the point is to make cygwin behave like *nix, wouldn't it be 
proper to use the method that most closely emulates it's behavior?


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.

A suggestion for a workaround:

Write a simple C program as a pipe for stdin -- that buffers
the I/O by 'line' (or xx bytes).  Then you can have it NOT do writes
of 0 bytes to MS progs.

You could even do it as a wrapper

avoidmsbug "normal progline with it's arguments"

avoid would open the appropriate pipes and do the buffering to
any buggy MS lib...

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.

Another approach in using the wrapper...  Just have your
real program be named "xxx".bin.exe, and let "xxx" be a link to 
"avoidmsbug.exe".  That prog could look at it's name, automatically append the 
".bin" to it's name to execute it...

Then you could have any number of cygwin programs with transparent wrappers
around them designed to deal with calling programs that mishandle pipe I/O...?


--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019