[Mono-bugs] [Bug 45302][Cos] Changed - Mono should throw bug when getting exit code of unfinished process

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 26 Jun 2003 14:19:56 -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 gert.driesen@pandora.be.

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

--- shadow/45302	Wed Jun 25 14:58:50 2003
+++ shadow/45302.tmp.6430	Thu Jun 26 14:19:56 2003
@@ -117,6 +117,51 @@
 But when I specify a lower timeout eg. 8000 milliseconds everything
 works fine.
 
 So I assume Process.WaitForExit doesn't handle Int32.MaxValue as
 timeout very well.
 
+
+------- Additional Comments From gert.driesen@pandora.be  2003-06-26 14:19 -------
+Apparently Mono does not handle Process.WaitForExit(Int32.MaxValue) 
+very well.  When I change the test case I provided to use 
+Int32.MaxValue as timeout, it immediately returns exit code 259.
+
+Note:  this is not actually the behaviour I'm getting with NAnt : 
+when I use timeout Int32.MaxValue in NAnt I sometimes get exit code 
+259 but not always.  When I use another timeout value with NAnt (eg. 
+10000) it always works fine.
+
+When I looked at the WaitForExit source code in Process.cs, I also 
+notice something strange :
+
+  * Waits up to ms milliseconds for process 'handle' to
+   * exit.  ms can be <0 to mean wait forever.
+   */
+  [MethodImplAttribute(MethodImplOptions.InternalCall)]
+  private extern bool WaitForExit_internal(IntPtr handle,
+        int ms);
+
+  public void WaitForExit() {
+   WaitForExit_internal(process_handle, -1);
+  }
+
+  public bool WaitForExit(int milliseconds) {
+   return(WaitForExit_internal(process_handle,
+          milliseconds));
+  }
+
+why doesn't the parameterless WaitForExit call WaitForExit with value
+Int32.MaxValue ?  This is how its done in Rotor and in my opinion 
+it's the right thing to do.  But in order to get this working right, 
+we should change the last method as follows (as WaitForExit_internal 
+expects -1 when you want to wait indefinitely) :
+
+  public bool WaitForExit(int milliseconds) {
+        if (milliseconds == int.MaxValue) {
+            milliseconds = -1;
+        }
+
+       return(WaitForExit_internal(process_handle,
+          milliseconds));
+  }
+