[Mono-bugs] [Bug 75469][Blo] New - Unexpected runtime exit when using Process redirection

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jul 5 06:33:08 EDT 2005


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 colin at breame.net.

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

--- shadow/75469	2005-07-05 06:33:08.000000000 -0400
+++ shadow/75469.tmp.4116	2005-07-05 06:33:08.000000000 -0400
@@ -0,0 +1,94 @@
+Bug#: 75469
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: SuSE 9.2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: colin at breame.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Unexpected runtime exit when using Process redirection
+
+Below is a program that on my system replicates an unexpected exit by the 
+mono  
+runtime. 
+ 
+The lines of interest are: 
+ 
+        stdout.WriteLine("1"); 
+        p.StandardInput.WriteLine("hello world!"); 
+        stdout.WriteLine("2"); 
+ 
+As the program runs, it prints '1' but exits before '2' is printed. 
+ 
+Any ideas what might be going on here?  Could this be SIGPIPE related? 
+ 
+--- 
+ 
+   
+using System;   
+using System.IO;   
+using System.Diagnostics;   
+   
+public class main_t {   
+   
+        public static void Main() {   
+                while (true) {   
+                        run();   
+                }   
+        }   
+   
+        public static void run() {   
+                Process p = null;   
+   
+                try {   
+                        p = new Process();   
+   
+                        string pipe = "echo hello";   
+   
+                        int i = pipe.IndexOf(' ');   
+                        if (i == -1) {   
+                                p.StartInfo.FileName = pipe;   
+                        } else {   
+                                p.StartInfo.FileName = pipe.Substring(0,   
+i);   
+                                p.StartInfo.Arguments =  
+pipe.Substring(i+1,  pipe.Length-i-1);   
+                        }   
+   
+                        p.StartInfo.UseShellExecute = false;   
+                        p.StartInfo.RedirectStandardInput = true;   
+                        try {   
+                                p.Start();   
+                        } catch (Exception e) {   
+                                Console.Error.WriteLine("could not  
+execute:  {0}", pipe);   
+                                goto init_error;   
+                        }   
+   
+                        TextWriter stdout = Console.Out;   
+                        Console.SetOut(p.StandardInput);   
+                        stdout.WriteLine("1");   
+                        p.StandardInput.WriteLine("hello world!");   
+                        stdout.WriteLine("2");   
+                        Console.SetOut(stdout);   
+   
+                        p.StandardInput.Close();   
+   
+                        if (p != null) {   
+                                p.WaitForExit();   
+                        }   
+   
+                } finally {   
+                        if (p != null) p.Close();   
+                }   
+        init_error:;   
+        }   
+}


More information about the mono-bugs mailing list