Avoid useless search for pid 0

This commit is contained in:
Benny Baumann 2020-12-01 23:34:06 +01:00 committed by BenBE
parent d0e71cb75f
commit bd24664fc2
1 changed files with 5 additions and 0 deletions

View File

@ -382,6 +382,11 @@ static void ProcessList_buildTree(ProcessList* this) {
if (process->pid == ppid)
r = 0;
// On Linux both the init process (pid 1) and the root UMH kernel thread (pid 2)
// use a ppid of 0. As that PID can't exist, we can skip searching for it.
if (!ppid)
r = 0;
while (l < r) {
int c = (l + r) / 2;
pid_t pid = ((Process*)Vector_get(this->processes, c))->pid;