Kernel: Process::for_each_thread() should show the main thread of PID 0

This commit is contained in:
Andreas Kling 2019-11-26 21:25:11 +01:00
parent fe0aa2ca53
commit 86a9a52355
Notes: sideshowbarker 2024-07-19 11:03:15 +09:00

View file

@ -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<Thread&>(main_thread()));
return;
}
Thread::for_each([callback, my_pid](Thread& thread) -> IterationDecision {
if (thread.pid() == my_pid)
return callback(thread);