Re: + prctl-add-pr_setget_child_reaper-to-allow-simple-process-supervision .patch added to -mm tree

Kay Sievers
2011-08-19T12:44:46Z

On Fri, Aug 19, 2011 at 14:25, Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> On 08/19, Kay Sievers wrote:
>> +             /* find the first ancestor marked as child_subreaper */
>> +             for (reaper = father->real_parent;
>> +                  reaper != reaper->real_parent;
>
> This looks mysterious. This relies on the fact that INIT_TASK(tsk)
> sets .real_parent = tsk. "reaper != &init_task" looks much more clean.
>
> But. Now that you check ->has_child_subreaper before the lookup,
> this problem should go away? I mean, if ->has_child_subreaper == T
> then some of our parents is the userspace task. Even if it was
> spawned by kthread and then exited, we can't miss ->child_reaper
> in the parents chain.

That's right. We only ever look at 'flagged' processes now, and no
other than a userspace process can ever be tagged. We can just walk up
to ->child_reaper.

> Or I missed something?

I think that's right. I'll test it.

>> +             case PR_SET_CHILD_SUBREAPER:
>> +                     me->signal->is_child_subreaper = !!arg2;
>> +                     me->signal->has_child_subreaper = true;
>
> Hmm. This looks wrong... why do we set ->has_child_subreaper?

That's the flag we pass down to our childs, hence we need to set it here.

Kay