[bcl] Avoid waiting for events inside a finalizer in Process.WaitForExit () because...
authorZoltan Varga <vargaz@gmail.com>
Thu, 30 Mar 2017 01:42:01 +0000 (21:42 -0400)
committerGitHub <noreply@github.com>
Thu, 30 Mar 2017 01:42:01 +0000 (21:42 -0400)
mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs

index 2a5432d0ace9a56eb12090ae1f3b0aae7274756e..4fc2f7c2078c5888ea0abbc52d45632d8a33dede 100644 (file)
@@ -2569,11 +2569,6 @@ namespace System.Diagnostics {
                         signaled = false;
                     }
                 }
-            }
-            finally {
-                if( processWaitHandle != null) {
-                    processWaitHandle.Close();
-                }
 
                 // If we have a hard timeout, we cannot wait for the streams
                 if( output != null && milliseconds == -1) {
@@ -2583,6 +2578,11 @@ namespace System.Diagnostics {
                 if( error != null && milliseconds == -1) {
                     error.WaitUtilEOF();
                 }
+            }
+            finally {
+                if( processWaitHandle != null) {
+                    processWaitHandle.Close();
+                }
 
                 ReleaseProcessHandle(handle);