lkml.org 
[lkml]   [2017]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2017-01-23 13:08    [W:0.732 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site