mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 23:15:46 +00:00
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.
This commit is contained in:
parent
deb05fe7c2
commit
79a6f6cb5b
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user