From e3f65c8ec2fe81c50514dcf21c335e5d39c1a223 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 14 Sep 2017 17:10:39 -0300 Subject: Make 'c' key work with threads as well. --- Action.c | 2 +- Process.c | 2 ++ Process.h | 2 ++ ProcessList.c | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Action.c b/Action.c index 391716a5..a6394ac3 100644 --- a/Action.c +++ b/Action.c @@ -142,7 +142,7 @@ static void tagAllChildren(Panel* panel, Process* parent) { pid_t ppid = parent->pid; for (int i = 0; i < Panel_size(panel); i++) { Process* p = (Process*) Panel_get(panel, i); - if (!p->tag && p->ppid == ppid) { + if (!p->tag && Process_isChildOf(p, ppid)) { tagAllChildren(panel, p); } } diff --git a/Process.c b/Process.c index 394ca25d..6551afd7 100644 --- a/Process.c +++ b/Process.c @@ -172,6 +172,8 @@ typedef struct ProcessClass_ { #define As_Process(this_) ((ProcessClass*)((this_)->super.klass)) +#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_)) + }*/ static int Process_getuid = -1; diff --git a/Process.h b/Process.h index 43780a2f..5b8ffdba 100644 --- a/Process.h +++ b/Process.h @@ -151,6 +151,8 @@ typedef struct ProcessClass_ { #define As_Process(this_) ((ProcessClass*)((this_)->super.klass)) +#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_)) + #define ONE_K 1024L #define ONE_M (ONE_K * ONE_K) diff --git a/ProcessList.c b/ProcessList.c index aea57e7e..25ae1385 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -173,7 +173,7 @@ static void ProcessList_buildTree(ProcessList* this, pid_t pid, int level, int i for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { Process* process = (Process*) (Vector_get(this->processes, i)); - if (process->show && (process->tgid == pid || (process->tgid == process->pid && process->ppid == pid))) { + if (process->show && Process_isChildOf(process, pid)) { process = (Process*) (Vector_take(this->processes, i)); Vector_add(children, process); } -- cgit v1.2.3