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: Can't reliably redirect standard output from C# program in recent Cygwin


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

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



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


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