-
-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to display parents and children processes of filtered pro… #1139
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,6 +370,16 @@ void ProcessList_collapseAllBranches(ProcessList* this) { | |
} | ||
} | ||
|
||
static void ProcessList_filterChildern(ProcessList *this, pid_t pid, Hashtable *processFilter) { | ||
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { | ||
Process *p = (Process*) (Vector_get(this->processes, i)); | ||
if (p->pid != pid && Process_isChildOf(p, pid)) { | ||
Hashtable_put(processFilter, p->pid, (void*) 1); | ||
ProcessList_filterChildern(this, p->pid, processFilter); | ||
} | ||
} | ||
} | ||
|
||
void ProcessList_rebuildPanel(ProcessList* this) { | ||
ProcessList_updateDisplayList(this); | ||
|
||
|
@@ -392,14 +402,33 @@ void ProcessList_rebuildPanel(ProcessList* this) { | |
|
||
const int processCount = Vector_size(this->displayList); | ||
int idx = 0; | ||
|
||
// Mark Children and Parent for F4-Filter | ||
Hashtable* filteredProcesses = Hashtable_new(processCount, false); | ||
for (int i = 0; i < processCount; i++) { | ||
Process* p = (Process*)Vector_get(this->processes, i); | ||
pid_t ppid = Process_getParentPid(p); | ||
|
||
if (incFilter && !(String_contains_i(Process_getCommand(p), incFilter, true))) | ||
continue; | ||
|
||
if (this->settings->showChildrenInFilter) | ||
ProcessList_filterChildern(this, p->pid, filteredProcesses); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo Childern -> Children There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
do { | ||
yurenchen000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Hashtable_put(filteredProcesses, p->pid, (void*) 1); | ||
ppid = Process_getParentPid(p); | ||
p = Hashtable_get(this->processTable, ppid); | ||
} while (this->settings->showParentsInFilter && p && p->pid != p->ppid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we know from #1017 (which I still need to rebase/reimplement), in some cases two processes may be parents of each other and thus this loop becomes an infinite one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, |
||
} | ||
|
||
bool foundFollowed = false; | ||
|
||
for (int i = 0; i < processCount; i++) { | ||
Process* p = (Process*) Vector_get(this->displayList, i); | ||
|
||
if ( (!p->show) | ||
|| (this->userId != (uid_t) -1 && (p->st_uid != this->userId)) | ||
|| (incFilter && !(String_contains_i(Process_getCommand(p), incFilter, true))) | ||
|| (incFilter && !Hashtable_get(filteredProcesses, p->pid)) | ||
|| (this->pidMatchList && !Hashtable_get(this->pidMatchList, p->tgid)) ) | ||
continue; | ||
|
||
|
@@ -428,6 +457,7 @@ void ProcessList_rebuildPanel(ProcessList* this) { | |
|
||
this->panel->scrollV = currScrollV; | ||
} | ||
Hashtable_delete(filteredProcesses); | ||
} | ||
|
||
Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo Childern -> Children
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it