1

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 handles 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.

BЈовић
  • 62,405
  • 41
  • 173
  • 273
Poulo
  • 1,551
  • 3
  • 14
  • 22
  • So, this is a windows question? – BЈовић Aug 04 '11 at 12:10
  • Yes, windows. Sorry, forgot to mention that. – Poulo Aug 05 '11 at 04:26
  • Why do you want to replace the anon pipes with named ones? The main issue seems to be that anonymous pipes are created already set up, whereas with named pipes, you have to set up the initial connection before you can use them, so you have that extra work to do. – BrendanMcK Aug 05 '11 at 08:59
  • With anonymous pipes I am forced to have blocking calls to ReadFile() and WriteFile(). I want to set timeouts which is currently not possible. – Poulo Aug 12 '11 at 11:02

0 Answers0