Starting a process and reading it's output while running

  • Thread starter Thread starter Kyle0654
  • Start date Start date
K

Kyle0654

I've been searching for a solution to this problem for a while but
haven't hit upon anything yet.

Details:
[b:a09763528e]Using:[/b:a09763528e] MSVC++ .NET 2003
[b:a09763528e]App type:[/b:a09763528e] Windows Forms Application
(Managed C++)
[b:a09763528e]Description:[/b:a09763528e]
I'm creating a new Process using the Process class which runs a
command line program. However, sometimes the command line program
will pause and wait for user input, but will not send any output to
my program until the process has exited, so I end up in a deadlock -
not able to recognize a request for input (which I could handle by
sending input to the process). I want to know how to retrieve output
from the process as the process is running rather than right after
the process has exited.

I've found a few tutorials around the net, but most of these are for
C#. I think the solution will probably involve multi-threading, but
I'm not quite sure how to do it, not having had enough experience
with multiple threads.

Any help would be appreciated.
 
Kyle0654 said:
Anyone have any idea?

I was going to reply but I wasn't sure what you are asking exactly. :-)

But since you asked a second time ...

Do you know about pipes? Do you know that you can redirect the standard
output device of a ("child") process which you create to a pipe which you
monitor? When the "child" writes to the pipe, you read from it.

However, unless and until the child writes, you get nada.

On first reading your question I wasn't sure if you were asking if there is
some way of coaxing the child into writing before it wants. That would be
magic. :-)

The pipe technique is described here:
http://support.microsoft.com/?id=190351

Regards,
Will
 
Back
Top