diff options
author | Denis Lisov <dennis.lissov@gmail.com> | 2022-01-07 02:23:21 +0300 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2022-02-13 19:50:16 +0100 |
commit | 79a6f6cb5b9d059c9a70e67cc16157b28f5b8758 (patch) | |
tree | 2de6fbeaffadb885c9def343be5eb7bc6bbe969c | |
parent | deb05fe7c2dae62acc447d568e6521859f40db6f (diff) |
ProcessList_buildTree: skip hashtable if known root
Don't waste time looking up the parent if the current process is already
known to be a root process.
-rw-r--r-- | ProcessList.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ProcessList.c b/ProcessList.c index e86f6ea4..2e99041e 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -274,13 +274,17 @@ static void ProcessList_buildTree(ProcessList* this) { // If PID corresponds with PPID (e.g. "kernel_task" (PID:0, PPID:0) // on Mac OS X 10.11.6) regard this process as root. - if (process->pid == ppid) + if (process->pid == ppid) { process->isRoot = true; + continue; + } // 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) + if (!ppid) { process->isRoot = true; + continue; + } // We don't know about its parent for whatever reason if (ProcessList_findProcess(this, ppid) == NULL) |