Re: [PATCH 2/4] clone: add CLONE_PIDFD

From
Christian Brauner <christian@brauner.io>
Date
2019-04-15 11:42:21
Also in
lkml
Reply to
Oleg Nesterov, 2019-04-15
On Mon, Apr 15, 2019 at 12:52:09PM +0200, Oleg Nesterov wrote:
On 04/14, Christian Brauner wrote:
quoted
@@ -2260,6 +2363,10 @@ long _do_fork(unsigned long clone_flags,
 	}

 	put_pid(pid);
+
+	if (clone_flags & CLONE_PIDFD)
+		nr = pidfd;
+
Well, this doesn't look nice ...

CLONE_PARENT_SETTID doesn't look very usefule, so what if we add

	if ((clone_flags & (CLONE_PIDFD|CLONE_PARENT_SETTID)) ==
	                   (CLONE_PIDFD|CLONE_PARENT_SETTID))
		return ERR_PTR(-EINVAL);

at the start of copy_process() ?

Then it can do

	if (clone_flags & CLONE_PIDFD) {
		retval = pidfd_create(pid, &pidfdf);
		if (retval < 0)
			goto bad_fork_free_pid;
		retval = put_user(retval, parent_tidptr)
		if (retval < 0)
			goto bad_fork_free_pid;
	}
Uhhh Oleg, that is nifty. I have to say I like that a lot. This would
let us return the pid and the pidfd in one go and we can also start
pidfd numbering at 0.
Thread (40 messages) 40 messages, 13 authors, last reply 2019-05-05
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help