How to spawn a child process and redirect its STD IO using named pipes?
I need to spawn a child process and talk to it over STD IO. I want to use named pipes to do so. The application that I am writing (which spawns the process) is in C++.
Microsoft gives a good example (http://msdn.microsoft.com/en-us/library/ms682499%28v=vs.85%29.aspx) of how to do the above using anonymous pipes and mentions that redirecting can also be done using named pipes.
But just replacing anonymous pipes with named pipes in the example they have provided does not work. (I am assigning the han开发者_JAVA技巧dles returned by CreateNamedPipe() API to the hStdInput, hStdOutput members of the STARTUPINFO structure used to spawn the child process.)
What is the right way to do this? An example code snippet would be great.
NOTE: I cannot modify the child process behavior.
精彩评论