From bd24664fc2c85ba82950d20d9d38c12311bb8e23 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Tue, 1 Dec 2020 23:34:06 +0100 Subject: Avoid useless search for pid 0 --- ProcessList.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ProcessList.c') diff --git a/ProcessList.c b/ProcessList.c index 30cd0f03..499f36a0 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -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; -- cgit v1.2.3