From dd08fd4160ee549fc529bd1e819ffd3c54f62cd8 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 29 Mar 2017 21:42:01 -0400 Subject: [PATCH] [bcl] Avoid waiting for events inside a finalizer in Process.WaitForExit () because it can hang if the thread which sets the event is aborted during shutdown. Fixes #53843. (#4609) (#4617) --- .../services/monitoring/system/diagnosticts/Process.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs index 2a5432d0ace..4fc2f7c2078 100644 --- a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs +++ b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs @@ -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); -- 2.25.1