// System.Diagnostics.Process BUG? // // The code as-is below will open an xterm, then when you close it, it will open// another. Let it open a few (closing each one), then check the "ps" output, // you will notice a few defunct processes. // // The workaround is to call WaitForExit() (see below) - is this a bug, or are // we expected to do that anyway? // using System; using System.IO; using System.Diagnostics; public class ProcessTest { public static void Main (string [] args) { Process pc = new Process (); pc.StartInfo.FileName = "xterm"; pc.StartInfo.RedirectStandardOutput = true; pc.StartInfo.UseShellExecute = false; pc.Start (); StreamReader pout = pc.StandardOutput; while (pout.ReadLine() != null); pout.Close (); // WORKAROUND: WaitForExit() will wait(2) on the task //pc.WaitForExit (); pc.Close (); Main (null); } }