summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/linux32/linux32_machdep.c13
-rw-r--r--sys/i386/linux/linux_machdep.c14
2 files changed, 25 insertions, 2 deletions
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index edeefc9..a792e72 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -472,20 +472,31 @@ int
linux_vfork(struct thread *td, struct linux_vfork_args *args)
{
int error;
+ struct proc *p2;
#ifdef DEBUG
if (ldebug(vfork))
printf(ARGS(vfork, ""));
#endif
- if ((error = vfork(td, (struct vfork_args *)args)) != 0)
+ /* exclude RFPPWAIT */
+ if ((error = fork1(td, RFFDG | RFPROC | RFMEM, 0, &p2)) != 0)
return (error);
+ if (error == 0) {
+ td->td_retval[0] = p2->p_pid;
+ td->td_retval[1] = 0;
+ }
/* Are we the child? */
if (td->td_retval[1] == 1)
td->td_retval[0] = 0;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
+ /* wait for the children to exit, ie. emulate vfork */
+ PROC_LOCK(p2);
+ while (p2->p_flag & P_PPWAIT)
+ msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+ PROC_UNLOCK(p2);
return (0);
}
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index a1dc8f7..4bb457b 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -316,20 +316,32 @@ int
linux_vfork(struct thread *td, struct linux_vfork_args *args)
{
int error;
+ struct proc *p2;
#ifdef DEBUG
if (ldebug(vfork))
printf(ARGS(vfork, ""));
#endif
- if ((error = vfork(td, (struct vfork_args *)args)) != 0)
+ /* exclude RFPPWAIT */
+ if ((error = fork1(td, RFFDG | RFPROC | RFMEM, 0, &p2)) != 0)
return (error);
+ if (error == 0) {
+ td->td_retval[0] = p2->p_pid;
+ td->td_retval[1] = 0;
+ }
/* Are we the child? */
if (td->td_retval[1] == 1)
td->td_retval[0] = 0;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
+ /* wait for the children to exit, ie. emulate vfork */
+ PROC_LOCK(p2);
+ while (p2->p_flag & P_PPWAIT)
+ msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+ PROC_UNLOCK(p2);
+
return (0);
}
OpenPOWER on IntegriCloud