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);