summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authornetchild <netchild@FreeBSD.org>2006-08-25 11:59:56 +0000
committernetchild <netchild@FreeBSD.org>2006-08-25 11:59:56 +0000
commitfedc5604a01292926d7d8537fae5de0fdba09877 (patch)
tree0f5ffddd061f8d6dd0dacb235f8ce484f5bb0ec0 /sys/amd64
parentcd0b41ad37004d2b72526d566192f69df0ed1546 (diff)
downloadFreeBSD-src-fedc5604a01292926d7d8537fae5de0fdba09877.zip
FreeBSD-src-fedc5604a01292926d7d8537fae5de0fdba09877.tar.gz
Emulate what vfork does instead of using it in linux_vfork. This way
we can do the stuff we need to do with linux processes at fork and don't panic the kernel at exit of the child. Submitted by: rdivacky Tested with: tst-vfork* (glibc regression tests) Tested by: netchild
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/linux32/linux32_machdep.c13
1 files changed, 12 insertions, 1 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);
}
OpenPOWER on IntegriCloud