Re: [PATCH 4/5] pidfd: add CLONE_WAIT_PID

From: Christian Brauner
Date: Thu Jul 25 2019 - 14:05:20 EST


On Thu, Jul 25, 2019 at 12:35:44PM +0200, Oleg Nesterov wrote:
> On 07/24, Christian Brauner wrote:
> >
> > If CLONE_WAIT_PID is set the newly created process will not be
> > considered by process wait requests that wait generically on children
> > such as:
>
> I have to admit this feature looks a bit exotic to me...

It might look like it from the kernels perspective but from the feedback
on this when presenting on this userspace has real usecases for this.

>
> > --- a/kernel/exit.c
> > +++ b/kernel/exit.c
> > @@ -1019,6 +1019,9 @@ eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p)
> > if (!eligible_pid(wo, p))
> > return 0;
> >
> > + if ((p->flags & PF_WAIT_PID) && (wo->wo_type != PIDTYPE_PID))
> > + return 0;
>
> Even if ptrace == T ?
>
> This doesn't look right. Say, strace should work even if its tracee (or
> one of the tracees) has PF_WAIT_PID.

As in
if (!ptrace && (p->flags & PF_WAIT_PID) && (wo->wo_type != PIDTYPE_PID))
return 0;

Sure, we can allow that.

Christian