Index: sys/compat/linux/linux_fork.c =================================================================== --- sys/compat/linux/linux_fork.c +++ sys/compat/linux/linux_fork.c @@ -82,6 +82,7 @@ linux_proc_init(td, td2, 0); td->td_retval[0] = p2->p_pid; + td->td_retval[1] = 0; /* * Make this runnable after we are finished with it. @@ -106,21 +107,16 @@ printf(ARGS(vfork, "")); #endif - /* Exclude RFPPWAIT */ - if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2, - NULL, 0, NULL)) != 0) + if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED, + 0, &p2, NULL, 0, NULL)) != 0) return (error); - td2 = FIRST_THREAD_IN_PROC(p2); linux_proc_init(td, td2, 0); - PROC_LOCK(p2); - p2->p_flag |= P_PPWAIT; - PROC_UNLOCK(p2); - td->td_retval[0] = p2->p_pid; + td->td_retval[1] = 0; /* * Make this runnable after we are finished with it. @@ -130,12 +126,6 @@ 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); } @@ -179,6 +169,9 @@ if (args->parent_tidptr == NULL) return (EINVAL); + if (args->flags & LINUX_CLONE_VFORK) + ff |= RFPPWAIT; + error = fork1(td, ff, 0, &p2, NULL, 0, NULL); if (error) return (error); @@ -228,12 +221,6 @@ 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. */ @@ -243,14 +230,7 @@ thread_unlock(td2); td->td_retval[0] = p2->p_pid; - - 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); - } + td->td_retval[1] = 0; return (0); } @@ -377,6 +357,7 @@ thread_unlock(newtd); td->td_retval[0] = newtd->td_tid; + td->td_retval[1] = 0; return (0);