This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin passes through null writes to other software when redirecting standard input/output (i.e. piping)


On Wed, May 09, 2012 at 07:21:34PM -0000, James Johnston wrote:
>On Wed, May 09, 2012 at 11:59:58AM -0700, Linda Walsh, the dead discussion resurrector 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.
>
>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:

You're being naive.  Of course this is harder than it looks.  Or, if it
really is so easy, why haven't you submitted a patch or at least a
proof of concept?

># Byte pipe used because Win32Program.exe does not link with CYGWIN1.DLLL
>cat Testfile.txt | ./Win32Program.exe

In the above, the series of events are likely something like:

1) Shell creates a pipe

2) Shell starts cat with its stdout set to the output side of the pipe, first
closing the input side.

3) Shell starts ./Win32Program.exe with its input set to the input side of
the pipe, first closing the output side.

4) Shell closes pipe.

5) Processes execute.

The cygwin DLL can't intercede here.  It's not some superior process
controlling I/O.  It's just a DLL used by two programs.  cat is writing
to the stdout that it inherited from the shell.  It doesn't know (and
shouldn't know) what's on the other end of the pipe and that it should
be changing the mode of the pipe.

Please stop thinking that there is a simple solution that you can
intuit without fully understanding how Cygwin works.

1.7.15 will contain a new CYGWIN option "pipe_byte" which will force
non-tty, non-fifo pipes to use byte mode.  That's about as far as we're
willing to modify Cygwin for this apocalyptic problem.

cgf

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]