0

Here is the problem, I want to use createprocess to run a command in a win32 console program, but I want to be able to search through the stdout, stderr, and stdin after modifying data being sent in to the process. This is so I can do some things underneath the hood and in some cases spawn an email which contains parts of the stdout and stderr. I have found some examples of how to redirect the output to a file, but it isn't a file that I need since I want the output for manipulation and real time information access; waiting for the process to end before I get the full output is not an option since it will run for 10-20 days. How can I create a process in win32 while being able to have access to the data coming out of stdout as a string stream, or like in nature, to achieve the goal I desire? Can some one direct me to an example of this?

Rusty Weber
  • 1,541
  • 1
  • 19
  • 32

1 Answers1

1

You have to use CreatePipe() to create pipes for CreateProcess() to use for the redirection. You would then read the process's output from the pipes as needed.

If you want the output in a stringstream, you have to read it from the pipe first and then assign it to the stringstream afterwards, or implement a custom streambuf or istream to grab the data from the pipes directly.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770