diff options
author | netchild <netchild@FreeBSD.org> | 2006-08-25 11:59:56 +0000 |
---|---|---|
committer | netchild <netchild@FreeBSD.org> | 2006-08-25 11:59:56 +0000 |
commit | fedc5604a01292926d7d8537fae5de0fdba09877 (patch) | |
tree | 0f5ffddd061f8d6dd0dacb235f8ce484f5bb0ec0 /sys/i386 | |
parent | cd0b41ad37004d2b72526d566192f69df0ed1546 (diff) | |
download | FreeBSD-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/i386')
-rw-r--r-- | sys/i386/linux/linux_machdep.c | 14 |
1 files changed, 13 insertions, 1 deletions
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); } |