From bdaf7cddcbe23315083f58cafd5141fa939ff69d Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 11 Apr 2023 23:28:16 +0300 Subject: [PATCH] Kernel: Process now locks the mutex while modifying open files This allows processes to be actually removed from the list instead of dead locking --- kernel/kernel/Process.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 211c5d15..1236fb2f 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -53,9 +53,11 @@ namespace Kernel void Process::exit() { - LockGuard _(m_lock); - for (auto* thread : m_threads) - thread->terminate(); + { + LockGuard _(m_lock); + for (auto* thread : m_threads) + thread->terminate(); + } while (!m_threads.empty()) PIT::sleep(1); for (auto& open_fd : m_open_files)