I am trying to find some information on data limits related to stdout on Windows. I can’t seem to find the information on MSDN.
-
Is there a limit to how much data can be written to stdout? If so, what happens if the limit is reached? Is the data lost?
-
If stdout is redirected (for example, by launching the process from .Net and using the ProcessStartInfo.RedirectStandardOutput property), does that have any effect on how much data can be written? As I read from the stdout stream in the calling process, does that affect the limitations?
-
Are these limits related in any way to named pipes?
It depends where it’s going – but yes, if you redirect the output in .NET you can easily run into problems if you don’t read the output. When the buffer runs out, writes to stdout in the child process will block. One common-ish cause of deadlock is a “parent” process waiting for the “child” to exit, and then reading the output – that won’t work if the child needs the parent to read the output to free up buffer space.
.NET has made this slightly easier by allowing an event-driven approach with
Process.OutputDataReceivedandProcess.ErrorDataReceived. This means you don’t need to start two threads (one to read stdout, one to read stderr) just to keep the process from blocking…