From 875002aead967904321a318754e7ce5dc38d46fa Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Fri, 23 Oct 2015 14:41:23 +0200 Subject: [PATCH] mx_proc: Use pgrp in addition to ppid to group processes --- mx_proc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mx_proc.c b/mx_proc.c index 611cda8b..1739ae84 100644 --- a/mx_proc.c +++ b/mx_proc.c @@ -269,11 +269,11 @@ static struct mx_proc_tree_node *mx_proc_tree_add(struct mx_proc_tree *pt, struc /* new is second to last roots parent? -> collect */ current = pt->root; while (current->next) { - if (current->next->pinfo.pstat->ppid != new->pinfo.pstat->pid) { + if (ppid_or_pgrp(current->next->pinfo.pstat) != new->pinfo.pstat->pid) { current = current->next; continue; } - assert(current->next->pinfo.pstat->ppid == new->pinfo.pstat->pid); + assert(ppid_or_pgrp(current->next->pinfo.pstat) == new->pinfo.pstat->pid); /* disconnect next */ next = current->next; @@ -286,7 +286,7 @@ static struct mx_proc_tree_node *mx_proc_tree_add(struct mx_proc_tree *pt, struc } /* new is first roots parent? -> new is new root */ - if (pt->root->pinfo.pstat->ppid == new->pinfo.pstat->pid) { + if (ppid_or_pgrp(pt->root->pinfo.pstat)== new->pinfo.pstat->pid) { assert(!new->next); current = pt->root; @@ -303,8 +303,7 @@ static struct mx_proc_tree_node *mx_proc_tree_add(struct mx_proc_tree *pt, struc } } - - parent = mx_proc_tree_find_by_pid(pt->root, new->pinfo.pstat->ppid); + parent = mx_proc_tree_find_by_pid(pt->root, ppid_or_pgrp(new->pinfo.pstat)); if (parent) { new->parent = parent; mx_proc_tree_add_to_list_sorted(&parent->childs, new);