开发者

How to spawn a child process and redirect its STD IO using named pipes?

开发者 https://www.devze.com 2023-03-26 00:39 出处:网络
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++.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号