473,738 Members | 10,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 100milliesecond s and give up" would be ok, but
I can't see how to do that either.
any ideas?

Thanks

Aug 21 '07 #1
3 2012
Not sure how you are doing your I/O but iostream and streamreader have Peek
methods. Hope this helps.
--
Thom
"bo**********@h otmail.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 100milliesecond s 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...@ho tmail.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.c omwrote:
On Aug 21, 12:44 pm, bob_jeffc...@ho tmail.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
412
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 info on CDs. Using either the StandardError or StandardOutput streams read, readline or peek methods causes an immediate block that doesn't release until the console app finishes it's business. I want to launch this console app and update my UI to...
2
3384
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 perl programs. I am able to read the output if it is ASCII (or some char of some sort). But the issues comes when it is binary info. I have tried to use StandardOutput.BaseStream, which returns a Stream to then read the bytes out of that...
0
939
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 virtual address space) and further, what happens when you do things like load a DLL into the process. Any help would be greatly appreciated. Thanks...
4
3351
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 that the asp.net worker process has restarted or that it is 'stalled' and is about to be restarted I read from techNet that I can tweak processModel attributes from my machine.config, particularly the attribute responseDeadlockInterval The...
0
1294
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 files\IrfanView\i_view32.exe" Private startuppath As String = Environment.CurrentDirectory & "\" Private pngimage As String = startuppath & "verify.png" Private png2pnm As String = startuppath & "png2pnm.exe" Private gocr As String = startuppath & "gocr.exe"...
1
6303
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 about it. Server was unable to process request. --> An error occured while trying to load validation schemas. --> Value cannot be null. Parameter name: path PLEASE HEEEELLPP!!
0
854
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 that occasionally the system reports an error of the type: ************** Exception Text **************
2
2429
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 however how to detect which data I am getting corresponds to the "text region" and not the other regions, like the stack. Does the type "MEM_IMAGE" defined in the "Type" parameter of the MEMORY_BASIC_INFORMATION structure define the read in memory...
11
5064
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 SetWindowPos method does not work. If I run the code as it is presented below, app.exe launches in its own window and is displayed at the top left part of the screen. However it isn't repositioned which is what the last piece of code should do. HOWEVER if...
0
8969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.