aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_fork.c
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2016-03-08 15:08:22 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2016-03-08 15:08:22 +0000
commit9f4e66afb98b2525f105d1be8f81996bd1912687 (patch)
treed468e951ab3211582dfebaeb9ce81a197d0b5790 /sys/compat/linux/linux_fork.c
parent388bc30115924230a8d6861e004c619dc4a4994f (diff)
downloadsrc-9f4e66afb98b2525f105d1be8f81996bd1912687.tar.gz
src-9f4e66afb98b2525f105d1be8f81996bd1912687.zip
Link the newly created process to the corresponding parent as
if CLONE_PARENT is set, then the parent of the new process will be the same as that of the calling process. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=296501
Diffstat (limited to 'sys/compat/linux/linux_fork.c')
-rw-r--r--sys/compat/linux/linux_fork.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c
index c12f198fe79b..94d9df5d8020 100644
--- a/sys/compat/linux/linux_fork.c
+++ b/sys/compat/linux/linux_fork.c
@@ -222,6 +222,18 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args)
if (args->flags & LINUX_CLONE_SETTLS)
linux_set_cloned_tls(td2, args->tls);
+ /*
+ * If CLONE_PARENT is set, then the parent of the new process will be
+ * the same as that of the calling process.
+ */
+ if (args->flags & LINUX_CLONE_PARENT) {
+ sx_xlock(&proctree_lock);
+ PROC_LOCK(p2);
+ proc_reparent(p2, td->td_proc->p_pptr);
+ PROC_UNLOCK(p2);
+ sx_xunlock(&proctree_lock);
+ }
+
#ifdef DEBUG
if (ldebug(clone))
printf(LMSG("clone: successful rfork to %d, "