diff --git a/src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs b/src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs index 826ed224cadf39..3b42c400d57695 100644 --- a/src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs +++ b/src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs @@ -306,16 +306,19 @@ static bool CollectCrashDumpWithCreateDump(Process process, string crashDumpPath else { // Workaround for https://github.com/dotnet/runtime/issues/93321 - for (int i = 0; i < 5; i++) + const int MaxRetries = 5; + for (int i = 0; i < MaxRetries; i++) { try { createdump.Kill(entireProcessTree: true); break; } - catch (Exception e) + catch (Exception e) when (i < MaxRetries - 1) { - Console.WriteLine($"Process.Kill(entireProcessTree: true) failed with {e}. Retrying."); + Console.WriteLine($"Process.Kill(entireProcessTree: true) failed:"); + Console.WriteLine(e); + Console.WriteLine("Retrying..."); } } }