473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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

May 6 '06 #1
4 4474
> 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.


Not sure, but I think the article at
http://msdn.microsoft.com/library/de...ui07152003.asp
might help.

Chris Jobson
May 6 '06 #2
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

"Chris Jobson" <ch**********@btinternet.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.


Not sure, but I think the article at
http://msdn.microsoft.com/library/de...ui07152003.asp
might help.

Chris Jobson

May 6 '06 #3
<a@b> wrote in message news:eE**************@TK2MSFTNGP04.phx.gbl...
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.
If you're checking whether the input is at the end/empty/etc, you might need
a Stream, not a TextReader. Can you use Console.OpenStandardInput() instead
of Console.In, which returns a Stream object and you can use CanRead, etc.?

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

"Chris Jobson" <ch**********@btinternet.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.


Not sure, but I think the article at
http://msdn.microsoft.com/library/de...ui07152003.asp
might help.

Chris Jobson


May 12 '06 #4
Hello !

Thanks a lot for your investigation.
I came not onto this idea.
Sad to say, even this is not working.
The stream has no ".Peek()" method. Because the returned stream is not
seekable, it has
wether a position or a length :-( :-(

Thanks,
Manfred

"Ben Voigt" <rb*@nospam.nospam> wrote in message
news:eO**************@TK2MSFTNGP03.phx.gbl...
<a@b> wrote in message news:eE**************@TK2MSFTNGP04.phx.gbl...
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.


If you're checking whether the input is at the end/empty/etc, you might
need a Stream, not a TextReader. Can you use Console.OpenStandardInput()
instead of Console.In, which returns a Stream object and you can use
CanRead, etc.?

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

"Chris Jobson" <ch**********@btinternet.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.

Not sure, but I think the article at
http://msdn.microsoft.com/library/de...ui07152003.asp
might help.

Chris Jobson



May 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
5
by: Hugh Welford | last post by:
Hi, is it possible to open a page in a new window with response.redirect, and if so, what is the syntax Thanks Hugh
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
10
by: seema_coma | last post by:
Iam working on Client, Server programming on Linux in C++. I have a Server Daemon running in the background, my client program talks to the Server and extracts some data which I am printing on the...
3
by: rahul8143 | last post by:
hello, I am trying following code but it has errors how to solve that and please help to know difference between value assigned to pointer/reference? #include <stdio.h> void main() { int i;...
2
by: Mark Dengler | last post by:
Is it possible to do a Response.Redirect to multiple URLs? I have tried the following and it simply ignores the first redirect: Response.Redirect("test.aspx", false);...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
13
by: Tim | last post by:
Hello, Is there a way to "cancel" a response.Redirect? For example, in the code below, could I insert anything in the Catch statement that would cancel the redirect and resume flow after the...
8
by: Mantorok | last post by:
Hi all When I start a new thread that tries to call: HttpContext.Current.Response.Redirect() It fails as Current returns null, is there anyway to access the current httpcontext from within...
8
by: Darrel | last post by:
I'm helping convert a 300+ page .html site into an ASP.net site. The client wants to set up 301 redirects for all of the old html pages. I've used ISAPI for this type of thing in the past, as it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.