Kernel/Tasks: Allow Kernel processes to be shut down

Since we never check a kernel process's state like a userland process,
it's possible for a kernel process to ignore the fact that someone is
trying to kill it, and continue running. This is not desireable if we
want to properly shutdown all processes, including Kernel ones.
This commit is contained in:
kleines Filmröllchen 2023-06-27 15:19:39 +02:00 committed by Jelle Raaijmakers
commit 021fb3ea05
Notes: sideshowbarker 2024-07-17 02:42:21 +09:00
7 changed files with 22 additions and 9 deletions

View file

@ -327,7 +327,7 @@ size_t Plan9FS::adjust_buffer_size(size_t size) const
void Plan9FS::thread_main()
{
dbgln("Plan9FS: Thread running");
do {
while (!Process::current().is_dying()) {
auto result = read_and_dispatch_one_message();
if (result.is_error()) {
// If we fail to read, wake up everyone with an error.
@ -342,7 +342,7 @@ void Plan9FS::thread_main()
dbgln("Plan9FS: Thread terminating, error reading");
return;
}
} while (!m_thread_shutdown);
}
dbgln("Plan9FS: Thread terminating");
}
@ -356,6 +356,8 @@ void Plan9FS::ensure_thread()
auto [_, thread] = Process::create_kernel_process(process_name.release_value(), [&]() {
thread_main();
m_thread_running.store(false, AK::MemoryOrder::memory_order_release);
Process::current().sys$exit(0);
VERIFY_NOT_REACHED();
}).release_value_but_fixme_should_propagate_errors();
m_thread = move(thread);
}