Index: amd64/linux32/linux32_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/amd64/linux32/linux32_machdep.c,v
retrieving revision 1.46
diff -u -r1.46 linux32_machdep.c
--- amd64/linux32/linux32_machdep.c	11 Feb 2008 19:35:03 -0000	1.46
+++ amd64/linux32/linux32_machdep.c	14 Apr 2008 19:32:40 -0000
@@ -627,6 +627,7 @@
 	   	PROC_UNLOCK(p2);
 #endif
 		exit_signal = 0;
+		em->clone_flags = args->flags;
 	}
 
 	if (args->flags & LINUX_CLONE_CHILD_SETTID)
Index: i386/linux/linux_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_machdep.c,v
retrieving revision 1.80
diff -u -r1.80 linux_machdep.c
--- i386/linux/linux_machdep.c	11 Feb 2008 19:35:03 -0000	1.80
+++ i386/linux/linux_machdep.c	14 Apr 2008 19:32:40 -0000
@@ -469,6 +469,7 @@
 	   	PROC_UNLOCK(p2);
 #endif
 	 	exit_signal = 0;
+		em->clone_flags = args->flags;
 	}
 
 	if (args->flags & LINUX_CLONE_CHILD_SETTID)
Index: compat/linux/linux_emul.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_emul.c,v
retrieving revision 1.20
diff -u -r1.20 linux_emul.c
--- compat/linux/linux_emul.c	2 Apr 2007 18:38:13 -0000	1.20
+++ compat/linux/linux_emul.c	14 Apr 2008 19:32:45 -0000
@@ -44,9 +44,6 @@
 #include <sys/sysproto.h>
 #include <sys/unistd.h>
 
-#include <compat/linux/linux_emul.h>
-#include <compat/linux/linux_futex.h>
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
@@ -55,6 +52,9 @@
 #include <machine/../linux/linux_proto.h>
 #endif
 
+#include <compat/linux/linux_emul.h>
+#include <compat/linux/linux_futex.h>
+
 struct sx	emul_shared_lock;
 struct mtx	emul_lock;
 
@@ -86,6 +86,7 @@
 		em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
 		em->pid = child;
 		em->pdeath_signal = 0;
+		em->clone_flags = 0;
 		if (flags & LINUX_CLONE_THREAD) {
 			/* handled later in the code */
 		} else {
@@ -123,6 +124,7 @@
 			 */
 			p_em = em_find(td->td_proc, EMUL_DONTLOCK);
 			KASSERT(p_em != NULL, ("proc_init: parent emuldata not found for CLONE_THREAD\n"));
+			em->clone_flags = p_em->clone_flags;
 			em->shared = p_em->shared;
 			EMUL_SHARED_WLOCK(&emul_shared_lock);
 			em->shared->refs++;
@@ -167,7 +169,8 @@
 	KASSERT(em != NULL, ("proc_exit: emuldata not found.\n"));
 
 	/* reparent all procs that are not a thread leader to initproc */
-	if (em->shared->group_pid != p->p_pid) {
+	if (em->shared->group_pid != p->p_pid &&
+	    (em->clone_flags & LINUX_CLONE_THREAD)) {
 		child_clear_tid = em->child_clear_tid;
 		EMUL_UNLOCK(&emul_lock);
 		sx_xlock(&proctree_lock);
Index: compat/linux/linux_emul.h
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_emul.h,v
retrieving revision 1.7
diff -u -r1.7 linux_emul.h
--- compat/linux/linux_emul.h	2 Apr 2007 18:38:13 -0000	1.7
+++ compat/linux/linux_emul.h	14 Apr 2008 19:32:45 -0000
@@ -52,6 +52,8 @@
 
 	int	pdeath_signal;		/* parent death signal */
 
+	l_int	clone_flags;		/* flags to linux_clone */
+
 	LIST_ENTRY(linux_emuldata) threads;	/* list of linux threads */
 };
 
Index: compat/linux/linux_misc.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.220
diff -u -r1.220 linux_misc.c
--- compat/linux/linux_misc.c	8 Apr 2008 09:45:47 -0000	1.220
+++ compat/linux/linux_misc.c	14 Apr 2008 19:32:45 -0000
@@ -75,10 +75,6 @@
 #include <vm/vm_object.h>
 #include <vm/swap_pager.h>
 
-#include <compat/linux/linux_sysproto.h>
-#include <compat/linux/linux_emul.h>
-#include <compat/linux/linux_misc.h>
-
 #ifdef COMPAT_LINUX32
 #include <machine/../linux32/linux.h>
 #include <machine/../linux32/linux32_proto.h>
@@ -91,6 +87,9 @@
 #include <compat/linux/linux_mib.h>
 #include <compat/linux/linux_signal.h>
 #include <compat/linux/linux_util.h>
+#include <compat/linux/linux_sysproto.h>
+#include <compat/linux/linux_emul.h>
+#include <compat/linux/linux_misc.h>
 
 #ifdef __i386__
 #include <machine/cputypes.h>
