Messages in this thread | | | Date | Mon, 23 Jan 2017 13:07:35 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH] introduce the walk_process_tree() helper |
| |
On 01/23, Oleg Nesterov wrote: > > Add the new helper to walk the process tree, the next patch adds a user. > Note that it visits the group leaders only, proc_visitor can do > for_each_thread itself or we can trivially extend walk_process_tree() to > do this.
Please consider this patch as a preparation for your change, or feel free to fold this code into your patch.
Now you can simply do
int xxx(struct task_struct *p, void *data) { if (p->signal->has_child_subreaper || is_child_reaper(task_pid(p)) return 0; p->signal->has_child_subreaper = 1; return 1; }
walk_process_tree(xxx, NULL);
walk_process_tree() handles the sub-threads correctly, but "p" is always the leader so is_child_reaper() is fine, but probably we need a new helper anyway.
Oleg.
| |