[Mono-bugs] [Bug 73227][Maj] Changed - System.Diagnostics.Process.WaitForExit hang

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 8 May 2005 11:10:23 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jonpryor@vt.edu.

http://bugzilla.ximian.com/show_bug.cgi?id=73227

--- shadow/73227	2005-05-07 15:58:55.000000000 -0400
+++ shadow/73227.tmp.28479	2005-05-08 11:10:23.000000000 -0400
@@ -93,6 +93,19 @@
 This is not a bug. When you redirect the output, you have to read it
 before waiting for exit (may be asynchronously), as the system has a
 limit for unread data in pipes.
 
 Windows fails too.
 
+
+------- Additional Comments From jonpryor@vt.edu  2005-05-08 11:10 -------
+As a follow-up, if you need to read all of
+StandardOutput/StandardError,  do StandardOutput.ReadToEnd() *before*
+calling WaitForExit():
+
+	string o = tarProcess.StandardOutput.ReadToEnd ();
+	tarProcess.WaitForExit ();
+	Console.WriteLine ("finished; r=" + tarProcess.ExitCode);
+	Console.WriteLine ("output=" + o);
+
+This allows everything to be read without causing the deadlocks in the
+original example.