From fedc5604a01292926d7d8537fae5de0fdba09877 Mon Sep 17 00:00:00 2001 From: netchild Date: Fri, 25 Aug 2006 11:59:56 +0000 Subject: 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 --- sys/i386/linux/linux_machdep.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'sys/i386/linux/linux_machdep.c') 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); } -- cgit v1.1