From e522a68ead8f87381918548c78d3615d18e26a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Wed, 22 Dec 2021 12:30:34 +0100 Subject: [PATCH] SEBWIN-524: Fixed possible deadlock in graceful termination mechanism for kiosk mode Disable Explorer Shell. --- SafeExamBrowser.WindowsApi/ExplorerShell.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.WindowsApi/ExplorerShell.cs b/SafeExamBrowser.WindowsApi/ExplorerShell.cs index 8f89cff1..69764c33 100644 --- a/SafeExamBrowser.WindowsApi/ExplorerShell.cs +++ b/SafeExamBrowser.WindowsApi/ExplorerShell.cs @@ -104,7 +104,7 @@ namespace SafeExamBrowser.WindowsApi nativeMethods.PostCloseMessageToShell(); logger.Debug("Waiting for explorer shell to terminate..."); - while (nativeMethods.GetShellWindowHandle() != IntPtr.Zero) + for (var elapsed = 0; nativeMethods.GetShellWindowHandle() != IntPtr.Zero && elapsed < THREE_SECONDS; elapsed += 20) { Thread.Sleep(20); } @@ -141,7 +141,7 @@ namespace SafeExamBrowser.WindowsApi var process = new System.Diagnostics.Process(); var taskkillPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "taskkill.exe"); - logger.Warn("Failed to gracefully terminate, attempting forceful termination..."); + logger.Warn("Failed to gracefully terminate explorer shell, attempting forceful termination..."); process.StartInfo.Arguments = $"/F /PID {processId}"; process.StartInfo.CreateNoWindow = true;