I used this MSDN code to hook stdout and stderr for a child process, (except that I'm calling PeekNamedPipe
first so that I don't block) and all is well except that for stdout if the process doesn't flush then I don't see the output of the process immediately. Stderr seems to be automatically flushed whenever something is sent to it, but stdout buffers the results.
Suddenly I'm amazed that the cmd.exe shell process can print results immediately when you step through code in Visual Studio. I would like to do so too. How does it do it?