[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190516152915.3t2wofeu3xsyhfbd@brauner.io>
Date: Thu, 16 May 2019 17:29:16 +0200
From: Christian Brauner <christian@...uner.io>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Aleksa Sarai <cyphar@...har.com>, jannh@...gle.com,
viro@...iv.linux.org.uk, torvalds@...ux-foundation.org,
linux-kernel@...r.kernel.org, arnd@...db.de,
akpm@...ux-foundation.org, dhowells@...hat.com,
ebiederm@...ssion.com, elena.reshetova@...el.com,
keescook@...omium.org, luto@...capital.net, luto@...nel.org,
tglx@...utronix.de, linux-alpha@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-ia64@...r.kernel.org,
linux-m68k@...ts.linux-m68k.org, linux-mips@...r.kernel.org,
linux-parisc@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-s390@...r.kernel.org, linux-sh@...r.kernel.org,
sparclinux@...r.kernel.org, linux-xtensa@...ux-xtensa.org,
linux-api@...r.kernel.org, linux-arch@...r.kernel.org,
linux-kselftest@...r.kernel.org, joel@...lfernandes.org,
dancol@...gle.com, serge@...lyn.com,
Geert Uytterhoeven <geert@...ux-m68k.org>
Subject: Re: [PATCH v1 1/2] pid: add pidfd_open()
On Thu, May 16, 2019 at 05:22:53PM +0200, Oleg Nesterov wrote:
> On 05/17, Aleksa Sarai wrote:
> >
> > On 2019-05-16, Oleg Nesterov <oleg@...hat.com> wrote:
> > > On 05/17, Aleksa Sarai wrote:
> > > > On 2019-05-16, Oleg Nesterov <oleg@...hat.com> wrote:
> > > > > On 05/16, Christian Brauner wrote:
> > > > > > With the introduction of pidfds through CLONE_PIDFD it is possible to
> > > > > > created pidfds at process creation time.
> > > > >
> > > > > Now I am wondering why do we need CLONE_PIDFD, you can just do
> > > > >
> > > > > pid = fork();
> > > > > pidfd_open(pid);
> > > >
> > > > While the race window would be exceptionally short, there is the
> > > > possibility that the child will die
> > >
> > > Yes,
> > >
> > > > and their pid will be recycled
> > > > before you do pidfd_open().
> > >
> > > No.
> > >
> > > Unless the caller's sub-thread does wait() before pidfd_open(), of course.
> > > Or unless you do signal(SIGCHILD, SIG_IGN).
> >
> > What about CLONE_PARENT?
>
> I should have mentioned CLONE_PARENT ;)
>
> Of course in this case the child can be reaped before pidfd_open(). But how often
> do you or other people use clone(CLONE_PARENT) ? not to mention you can trivially
> eliminate/detect this race if you really need this.
>
> Don't get me wrong, I am not trying to say that CLONE_PIDFD is a bad idea.
>
> But to me pidfd_open() is much more useful. Say, as a perl programmer I can easily
> use pidfd_open(), but not CLONE_PIDFD.
Right, but for a libc, service- or container manager CLONE_PIDFD is much
nicer when spawning processes quickly. :) I think both are very good to
have.
Thanks, Oleg. As always super helpful reviews. :)
Christian
Powered by blists - more mailing lists