473,396 Members | 1,975 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.

Reading StandardOutput from a Process (no deadlock please)

Hi,

I'm trying to read the output and write the input of a process using
its StandardOutput/Input and I'd really like to check if the process
is waiting for input or whether it has output ready to be read. Is it
possible? It seems like a fairly simple thing to try and do but most
of the "read" functions I've tried seem to deadlock if there's nothing
to read due the process waiting for output. It's rubbish!

Even a simple "try for 100millieseconds and give up" would be ok, but
I can't see how to do that either.
any ideas?

Thanks

Aug 21 '07 #1
3 1993
Not sure how you are doing your I/O but iostream and streamreader have Peek
methods. Hope this helps.
--
Thom
"bo**********@hotmail.com" wrote:
Hi,

I'm trying to read the output and write the input of a process using
its StandardOutput/Input and I'd really like to check if the process
is waiting for input or whether it has output ready to be read. Is it
possible? It seems like a fairly simple thing to try and do but most
of the "read" functions I've tried seem to deadlock if there's nothing
to read due the process waiting for output. It's rubbish!

Even a simple "try for 100millieseconds and give up" would be ok, but
I can't see how to do that either.
any ideas?

Thanks

Aug 21 '07 #2

On Aug 21, 12:44 pm, bob_jeffc...@hotmail.com wrote:
I'd really like to check if the process is waiting for input
I don't think this is possible. Are you sure you need it?
or whether it has output ready to be read.
See tbain's Peek() response.
deadlock
Technically, what you're describing is a "blocking read". Deadlocks
are (by definition) permanent.

Aug 21 '07 #3
On 21 Aug, 12:37, UL-Tomten <tom...@gmail.comwrote:
On Aug 21, 12:44 pm, bob_jeffc...@hotmail.com wrote:
I'd really like to check if the process is waiting for input

I don't think this is possible. Are you sure you need it?
or whether it has output ready to be read.

See tbain's Peek() response.
deadlock

Technically, what you're describing is a "blocking read". Deadlocks
are (by definition) permanent.
Thanks for the responses.

I had a go with Peek(), but it's not great as sometimes it answers -1
but you can still do a successful ReadLine(). Think it may be
answering -1 for an empty line.

It's quite annoying.

Oh well, thanks anyway

Aug 21 '07 #4

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

Similar topics

0
by: John Lewin | last post by:
I've recently discovered the value of using existing console applications in managed .net apps. Unfortunately, I've stumbled into a problem with a particular console application that check's crc...
2
by: dansan | last post by:
I have been tryning to make some of our C# programs talk to some perl programs. These perl jewels output in binary. I have been trying to use Process.StandardOutput to read the output from the...
0
by: Ben R. | last post by:
Could someone point me to some good tutorials on Windows Memory? Specifically, I'd like an indepth look at when a process loads, what its "view" of its memory is (I think this is refered to as...
4
by: Sefi | last post by:
Good day everyone I'm a bit confused about whether the "Server Application Unavailable" status of my website that frequently occurs when several users are simultaneously logged into it is a symptom...
0
by: CMG | last post by:
I am trying to run gocr from my program, and use the output. I have done this with success befor, with a workaround command line tool.: Private irfanview As String = "C:\program...
1
by: Modica82 | last post by:
I keep getting this error. I have no idea what is causing it. I get this when i try and consume a web service from a client?? Has anyone got any ideas of what this could be, i can find nothing...
0
by: almurph | last post by:
Hi everyone, Hope that you can help me please. I am parsing approx 1.34M record in a database. I read a line, parse it and then write out this new line to a new column. However I have notice...
2
by: patelj27b | last post by:
Hey There, I am trying to read the memory of the text region of a running process. I can open a process and read the data in the process using OpenProcess and ReadProcessMemory. I'm not sure...
11
by: garyusenet | last post by:
For this first time today I used the System.Diagnositcs namespace to launch a program from my c# code. The program launches OK but I have something which has completely stumped me. The...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.