svn commit: r293492 - stable/10/sys/compat/linux

Dmitry Chagin dchagin at FreeBSD.org
Sat Jan 9 15:12:32 UTC 2016


Author: dchagin
Date: Sat Jan  9 15:12:31 2016
New Revision: 293492
URL: https://svnweb.freebsd.org/changeset/base/293492

Log:
  To facillitate Linuxulator merging temporarilly revert r288994 (by bdrewery).

Modified:
  stable/10/sys/compat/linux/linux_fork.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linux/linux_fork.c
==============================================================================
--- stable/10/sys/compat/linux/linux_fork.c	Sat Jan  9 14:53:23 2016	(r293491)
+++ stable/10/sys/compat/linux/linux_fork.c	Sat Jan  9 15:12:31 2016	(r293492)
@@ -112,8 +112,9 @@ linux_vfork(struct thread *td, struct li
 		printf(ARGS(vfork, ""));
 #endif
 
-	if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED,
-	    0, &p2, NULL, 0)) != 0)
+	/* Exclude RFPPWAIT */
+	if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2,
+	    NULL, 0)) != 0)
 		return (error);
 
    	td->td_retval[0] = p2->p_pid;
@@ -122,6 +123,10 @@ linux_vfork(struct thread *td, struct li
 	if (error)
 		return (error);
 
+	PROC_LOCK(p2);
+	p2->p_flag |= P_PPWAIT;
+	PROC_UNLOCK(p2);
+
 	td2 = FIRST_THREAD_IN_PROC(p2);
 
 	/*
@@ -132,6 +137,12 @@ linux_vfork(struct thread *td, struct li
 	sched_add(td2, SRQ_BORING);
 	thread_unlock(td2);
 
+	/* wait for the children to exit, ie. emulate vfork */
+	PROC_LOCK(p2);
+	while (p2->p_flag & P_PPWAIT)
+		cv_wait(&p2->p_pwait, &p2->p_mtx);
+	PROC_UNLOCK(p2);
+
 	return (0);
 }
 
@@ -193,9 +204,6 @@ linux_clone(struct thread *td, struct li
 		if (args->parent_tidptr == NULL)
 			return (EINVAL);
 
-	if (args->flags & LINUX_CLONE_VFORK)
-		ff |= RFPPWAIT;
-
 	error = fork1(td, ff, 0, &p2, NULL, 0);
 	if (error)
 		return (error);
@@ -264,6 +272,12 @@ linux_clone(struct thread *td, struct li
 		    "stack %p sig = %d"), (int)p2->p_pid, args->stack,
 		    exit_signal);
 #endif
+	if (args->flags & LINUX_CLONE_VFORK) {
+	   	PROC_LOCK(p2);
+	   	p2->p_flag |= P_PPWAIT;
+	   	PROC_UNLOCK(p2);
+	}
+
 	/*
 	 * Make this runnable after we are finished with it.
 	 */
@@ -275,6 +289,14 @@ linux_clone(struct thread *td, struct li
 	td->td_retval[0] = p2->p_pid;
 	td->td_retval[1] = 0;
 
+	if (args->flags & LINUX_CLONE_VFORK) {
+		/* wait for the children to exit, ie. emulate vfork */
+		PROC_LOCK(p2);
+		while (p2->p_flag & P_PPWAIT)
+			cv_wait(&p2->p_pwait, &p2->p_mtx);
+		PROC_UNLOCK(p2);
+	}
+
 	return (0);
 }
 


More information about the svn-src-all mailing list