title: How does cmd.exe display stdout even though the process doesn't flush?
body: <p>I used <a href="https://docs.microsoft.com/en-us/windows/win32/procthread/creating-a-child-process-with-redirected-input-and-output" rel="nofollow noreferrer">this MSDN code</a> to hook stdout and stderr for a child process, (except that I'm calling <code>PeekNamedPipe</code> 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.</p>
  
  <p>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?</p>