[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190725165656.pbtmtm3hxxmj4aq6@brauner.io>
Date: Thu, 25 Jul 2019 18:56:57 +0200
From: Christian Brauner <christian@...uner.io>
To: Oleg Nesterov <oleg@...hat.com>
Cc: linux-kernel@...r.kernel.org, arnd@...db.de, ebiederm@...ssion.com,
keescook@...omium.org, joel@...lfernandes.org, tglx@...utronix.de,
tj@...nel.org, dhowells@...hat.com, jannh@...gle.com,
luto@...nel.org, akpm@...ux-foundation.org, cyphar@...har.com,
torvalds@...ux-foundation.org, viro@...iv.linux.org.uk,
kernel-team@...roid.com, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
linux-api@...r.kernel.org
Subject: Re: [PATCH 4/5] pidfd: add CLONE_WAIT_PID
On Thu, Jul 25, 2019 at 06:13:17PM +0200, Oleg Nesterov wrote:
> On 07/25, Christian Brauner wrote:
> >
> > The key is that you want to be able to create child processes in a
> > shared library without the main programing having to know about this so
> > that it can use P_ALL and never get stuff from the library.
>
> OK, thanks...
>
> in this case you should probablu pass 0 in CSIGNAL to ensure that the main
> program won't be notified when that child exits.
Yes, that's the idea. So you'd turn off SIGCHLD and rely on pidfd polling
only. That's similar to how pdfork() on FreeBSD works. It's just that we
need to do:
struct clone_args args = {
.exit_signal = 0,
.flags = CLONE_PIDFD | CLONE_WAIT_PID,
};
Now the shared library can guarantee that noone else in the mainloop
gets woken by a SIGCHLD from the pidfd-based helper process (because
exit_signal is 0) but afaict it also needs CLONE_WAIT_PID. Since the
latter allows it to guarantee that if someone in the mainloop gets
SIGCHLD from another regular process and calls waitid(P_ALL) it won't
accidently reap a pidfd-based process that has exited.
Fyi, I'm splitting CLONE_WAIT_PID out into a separate patchset and only
keep P_PIDFD for now. So we can discuss this independently. You think
that's better Oleg?
Christian
Powered by blists - more mailing lists