tags:

views:

247

answers:

2

Take the following C# file, the simplest possible repro of my problem:

using System;
using System.IO;

public static class Test
{
    public static void Main(string[] args)
    {
        string line;
        while ((line = Console.In.ReadLine()) != null)
        {
            Console.Out.WriteLine(line);
        }
    }
}

When I build this under mono and run it on the console, everything works fine except that I can't send EOF. Typing CTRL-D just puts a weird character on the command line. I think that I'm checking for EOF the wrong way, but Console.In is a TextReader, which doesn't have the EndOfFile property. How can I fix this?

+1  A: 

CTRL-D is the unix style end of file... because Mono derives from the Microsoft realm does it perhaps use CTRL-Z? (I don't have Mono installed, so I'm taking a shot in the dark here).

Godeke
Ctrl-D is EOT and Ctrl-Z is EOF. Ctrl-Z in at least sh and bash is used to stop a process running in foreground...
Gonzalo
Godeke
Those are stty variable names, not ASCII. It makes sense for a terminal that deals with text to consider EOT == EOF and treat it as the end of its input.
Gonzalo
+5  A: 

Which version of mono? I fixed that problem in r129444 in 2009-03-16... Your program runs as expected when I press Ctrl-D.

Update: Nice. I found out that 2.4.x.y versions don't have the fix :-(. It will be in the upcoming 2.6 version... Sorry about that. Update 2: mono-2-4 was branched on 2009-03-13. I missed it by 3 days!

Gonzalo
I see this problem in version 2.4.2.3 (tarball Tue Oct 6 15:35:40 MDT 2009), downloaded recently from mono-project.com
jleedev
Yeah, I just noticed that when trying his test with the system installed Mono instead of the built from sources (trunk) one.
Gonzalo
I'm using the mono that's in Ubuntu main. `mono --version` says 1.9.1... so well before your fix. Darn.
JSBangs
Looks like you have an old ubuntu too ;-)
Gonzalo
I hope that this bug gets backported to mono-2-4 ;-)
miguel.de.icaza
@miguel: it is in the mono-2-4 branch, just not in the mono-2-4-x series.
Gonzalo