Groups | Blog | Home
all groups > dotnet framework > may 2006 >

dotnet framework : Redirect StdIO-Problem: Console.In.Peek() hungs !


Manfred Braun
5/5/2006 5:09:02 PM
Hi All !

I think, there is a bug in the System.Console class related to use the
STDIO streams. I am doing a very simple thing in a console-based program
named CS [ConsoleTest]

Console.In.Peek();

and the program hungs if no parameters were provided on the commandline.
If I use simple redirection like "echo "hallo" | cs.exe"
everything is fine.

I thing this is a bug in the console class. Because I am delaing with
different streams, I need to pass "TextReader" instances to a method
and have to expect, that it works with all types of TextReaders well.

I have urgent needs, because I have to distribute an I/O-filter
very quickly. I am MSDN Universal Abonnent and can require support!

Thanks so far and
best regards,
Manfred

Note:There was a similar request [perhabs from a person, which has
possibly no validity of claim], but no answer! The request was:


Subject: Redirection from stdin 3/7/2006 6:29 AM PST
By: Stefano Del Furia In: microsoft.public.dotnet.framework
Chris Jobson
5/6/2006 11:34:22 AM
[quoted text, click to view]

Not sure, but I think the article at
http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraskdr/html/askgui07152003.asp
might help.

Chris Jobson

a NO[at]SPAM b
5/6/2006 1:42:10 PM
Hi Chris and All!

Thanks a lot, I could'nt find this article!

Practically, I cannot accept this to be a solution: I always pass a
TextReader to a method and inside this method, I have to recognize, if the
stream is at the end or empty. The method cannot know, if this comes from
the Console.In TextReader. Wraping around the OS layer is one of the
requirements of the Framework.

I think, there were several bad decision while developing about the Console
class:Why should I assume, the TextReader to be already open? I checked the
Console.In to be null, but is'nt. Doing many things "automatically" presents
you problems on another end. In the FileStream class, ther is the Handle
property ....It looks like doing a Peek() opens the TextReader instead of
checking it.

Additionally, I have to run this proggi(s) also on some Unix machines and
using the W32 API would make it platform dependent and also "offers" me some
code maintenance nightmare.

Thanks a lot and
best regards,
Manfred

[quoted text, click to view]

AddThis Social Bookmark Button