From 86a9a52355905e4ac71730dba5c325498fd05177 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 26 Nov 2019 21:25:11 +0100 Subject: [PATCH] Kernel: Process::for_each_thread() should show the main thread of PID 0 --- Kernel/Process.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Kernel/Process.h b/Kernel/Process.h index 31315c1557..476f1162c4 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -461,6 +461,13 @@ inline void Process::for_each_thread(Callback callback) const { InterruptDisabler disabler; pid_t my_pid = pid(); + + if (my_pid == 0) { + // NOTE: Special case the colonel thread, since its main thread is not in the global thread table. + callback(const_cast(main_thread())); + return; + } + Thread::for_each([callback, my_pid](Thread& thread) -> IterationDecision { if (thread.pid() == my_pid) return callback(thread);