delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/03/12/13:30:40

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
From: "James Johnston" <JamesJ AT motionview3d DOT com>
To: <cygwin AT cygwin DOT com>
References: <004e01ccfd70$c69af3f0$53d0dbd0$@motionview3d.com> <005c01ccfd79$6341f980$29c5ec80$@motionview3d.com> <loom DOT 20120309T021648-138 AT post DOT gmane DOT org> <007201ccfe25$130065e0$390131a0$@motionview3d.com> <20120309195247 DOT GB18960 AT calimero DOT vinschen DOT de> <20120311013339 DOT GA32518 AT ednor DOT casa DOT cgf DOT cx> <00b701cd0059$25c26a80$71473f80$@motionview3d.com> <20120312141929 DOT GE2382 AT calimero DOT vinschen DOT de>
In-Reply-To: <20120312141929.GE2382@calimero.vinschen.de>
Subject: RE: Can't reliably redirect standard output from C# program in recent Cygwin
Date: Mon, 12 Mar 2012 17:28:17 -0000
Message-ID: <00cf01cd0075$8430b290$8c9217b0$@motionview3d.com>
MIME-Version: 1.0
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q2CHUaxR016325

Well, good call.  I shouldn't have jumped to conclusions.  Both my C++ and C# examples still fail:

$  echo `./HelloCPP` ; echo `./HelloCS`



JamesJ AT JTJDEVTOOLS /cygdrive/c/Users/JamesJ/Desktop
$

I guess maybe it is a different bug.  I can provide binaries for these files if desired, but realistically I think anyone can compile it in MinGW, Visual C++, etc. using the C source code I posted earlier, for example.  This was using an up-to-date Cygwin, and I replaced the C:\cygwin\bin\cygwin1.dll with the one from the development snapshot from 3/10/2012.

Here is the source code for HelloCS program, compiled with Visual C# 2008 SP1:

class Program { static void Main(string[] args) { System.Console.Write("Hello"); } }

And again, here's the source code for HelloCPP program, compiled with Visual C++ 2008 SP1:

#include <windows.h>

int main()
{
	char * test = "AB";
	DWORD written;

	// Get standard output file handle
	HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);

	// Do a null write.  This breaks Cygwin when output is redirected.
	WriteFile(h, test, 0, &written, NULL);

	// Print an "A" and a "B" in two write operations
	WriteFile(h, test, 1, &written, NULL);
	WriteFile(h, test+1, 1, &written, NULL);
	return 0;
}

Obviously, neither of these binaries were linked against any Cygwin libraries... they are just straight 100% Win32 programs...  The benefit of the C version is that it removes the rest of .NET from the test... 

Best regards,

James Johnston

-----Original Message-----
Sent: Monday, March 12, 2012 14:19
Subject: Re: Can't reliably redirect standard output from C# program in recent Cygwin

On Mar 12 14:05, James Johnston wrote:
> You're partially correct, depending on how you look at it...  As I 
> wrote earlier, I reproduced it with a straight Win32 program, too - by 
> doing a null write that every C# program would do.  So I guess it's 
> not specific to C#, since C++ programs can cause it too.  But every C# 
> program would normally do this activity since the runtime always does 
> the null write - so in that sense, I guess it is somewhat specific to C#.
> 
> Thanks all, good to know it should be fixed. :)

Better test it.  Please try the latest developer snapshot from http://cygwin.com/snapshots/


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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


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