diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-12-01 23:34:06 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2020-12-02 23:50:05 +0100 |
commit | bd24664fc2c85ba82950d20d9d38c12311bb8e23 (patch) | |
tree | 1081a78807ee8dbdffb77e3bfab4aa76499e0aa6 | |
parent | d0e71cb75f088394b6a5c99a15cfe60fd6fbbc9d (diff) |
Avoid useless search for pid 0
-rw-r--r-- | ProcessList.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; |