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]

Can't reliably redirect standard output from C# program in recent Cygwin


Hi,

I have had some problems with calling a .NET program written in C# from
Cygwin.  I believe it is a bug introduced in recent versions of Cygwin.  I
have boiled it down to these simple steps to reproduce:

1.  Create a new virtual machine with Windows 7 64-bit RTM installed on it;
don't install any Windows updates.  (Note that I have also reproduced it on
a Windows 7 64-bit host machine that is up-to-date on updates.  I have not
tried on other versions of Windows.)

2.  Create a simple Hello World console application in Visual C# 2008 SP1:
(a) create new console application, (b) add the following line of code to
the Main function:

Console.Write("HelloWorld");

Compile the app as usual; I did the default Debug / Any CPU build.

3.  Install Cygwin: go to Cygwin.com, go to the install page and download
the public "setup.exe".  Install using defaults: nothing changed, and no
additional packages added.

4.  Some test results from the Cygwin prompt:

JamesJ@JTJDEVTOOLS /cygdrive/c/Users/JamesJ/Desktop
$ ./HelloCS.exe
HelloWorld
JamesJ@JTJDEVTOOLS /cygdrive/c/Users/JamesJ/Desktop
$ echo `./HelloCS.exe`


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

Here's the problem:  the "echo `./HelloCS.exe`" line did NOT print
HelloWorld.  Why not?  What is going on here - is it a bug in .NET or
Cygwin?  My guess is Cygwin... this problem did not occur when I had
previously updated Cygwin in January.

Oddly enough, using "echo `./HelloCS.exe | cat`" works some of the time, but
it's not 100% reliable!  Running "./HelloCS.exe | cat" at the terminal
doesn't always work, either.

Are there any changes to the .NET program that could be added to work around
this bug and get the "echo `./HelloCS.exe`" line to work again?  Any changes
to Cygwin to make?  What package in Cygwin might have introduced this bug
(assuming it is a Cygwin bug) and can I safely roll back my setup to a
working version?

I attached output from cygcheck.out.  I also attached my setup.log file.
These files are from my host development workstation that has more than just
the base Cygwin packages installed.  Note that I ran setup on Feb 29, 2012.
That is when I first noticed the problem.  The previous time I ran setup to
update everything was Jan 18, 2012 - the problem did not exist yet after
that update.

Best regards,

James Johnston

Attachment: cygcheck.out
Description: Binary data

Attachment: setup.log
Description: Binary data

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