Thread (13 messages) 13 messages, 5 authors, 2019-05-18

Re: [PATCH v1 1/2] pid: add pidfd_open()

From: Christian Brauner <christian@brauner.io>
Date: 2019-05-16 15:29:23
Also in: linux-alpha, linux-arch, linux-arm-kernel, linux-kselftest, linux-mips, linux-s390, linux-sh, linuxppc-dev, lkml, sparclinux

On Thu, May 16, 2019 at 05:22:53PM +0200, Oleg Nesterov wrote:
On 05/17, Aleksa Sarai wrote:
quoted
On 2019-05-16, Oleg Nesterov [off-list ref] wrote:
quoted
On 05/17, Aleksa Sarai wrote:
quoted
On 2019-05-16, Oleg Nesterov [off-list ref] wrote:
quoted
On 05/16, Christian Brauner wrote:
quoted
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,
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help