From 29aadc379a7611a47686c49d62938dd08eec0b8c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 17 Jul 2020 15:02:34 +0200 Subject: [PATCH] [xharness] Improve process killing a bit. * Log what we're doing. * Wait a bit after sending SIGABRT, to allow for the OS to create any crash reports. --- .../Execution/ProcessManager.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Execution/ProcessManager.cs b/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Execution/ProcessManager.cs index 788be8499279..a01f4878bf7b 100644 --- a/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Execution/ProcessManager.cs +++ b/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Execution/ProcessManager.cs @@ -277,12 +277,19 @@ static async Task KillTreeAsyncInternal (int pid, ILog log, bool? diagnostics = // Send SIGABRT since that produces a crash report // lldb may fail to attach to system processes, but crash reports will still be produced with potentially helpful stack traces. - for (int i = 0; i < pids.Count; i++) + for (int i = 0; i < pids.Count; i++) { + log.WriteLine ($"kill -6 {pids [i]}"); kill (pids [i], 6); + } + + // Wait a little bit for the OS to process the SIGABRTs + await Task.Delay (TimeSpan.FromSeconds (5)); // send kill -9 anyway as a last resort - for (int i = 0; i < pids.Count; i++) + for (int i = 0; i < pids.Count; i++) { + log.WriteLine ($"kill -9 {pids [i]}"); kill (pids [i], 9); + } } static async Task WaitForExitAsync (Process process, TimeSpan? timeout = null)