diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index e8ff6cbc7ac7..1f4945866c64 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -591,6 +591,14 @@ linux_clone(struct thread *td, struct linux_clone_args *args) error = fork1(td, ff, 0, &p2); if (error) return (error); + + if (args->flags & (CLONE_PARENT|CLONE_THREAD)) { + sx_xlock(&proctree_lock); + PROC_LOCK(p2); + proc_reparent(p2, td->td_proc->p_pptr); + PROC_UNLOCK(p2); + sx_xunlock(&proctree_lock); + } /* create the emuldata */ error = linux_proc_init(td, p2->p_pid, args->flags); @@ -610,14 +618,6 @@ linux_clone(struct thread *td, struct linux_clone_args *args) } } - if (args->flags & (CLONE_PARENT|CLONE_THREAD)) { - sx_xlock(&proctree_lock); - PROC_LOCK(p2); - proc_reparent(p2, td->td_proc->p_pptr); - PROC_UNLOCK(p2); - sx_xunlock(&proctree_lock); - } - if (args->flags & CLONE_THREAD) { /* XXX: linux mangles pgrp and pptr somehow * I think it might be this but I am not sure. diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index 47f65ce995c5..d07cbd53badc 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -438,6 +438,14 @@ linux_clone(struct thread *td, struct linux_clone_args *args) error = fork1(td, ff, 0, &p2); if (error) return (error); + + if (args->flags & (CLONE_PARENT|CLONE_THREAD)) { + sx_xlock(&proctree_lock); + PROC_LOCK(p2); + proc_reparent(p2, td->td_proc->p_pptr); + PROC_UNLOCK(p2); + sx_xunlock(&proctree_lock); + } /* create the emuldata */ error = linux_proc_init(td, p2->p_pid, args->flags); @@ -457,14 +465,6 @@ linux_clone(struct thread *td, struct linux_clone_args *args) } } - if (args->flags & (CLONE_PARENT|CLONE_THREAD)) { - sx_xlock(&proctree_lock); - PROC_LOCK(p2); - proc_reparent(p2, td->td_proc->p_pptr); - PROC_UNLOCK(p2); - sx_xunlock(&proctree_lock); - } - if (args->flags & CLONE_THREAD) { /* XXX: linux mangles pgrp and pptr somehow * I think it might be this but I am not sure.