It _should_ be reasonably straightforward to do vfork() by using clone().
It would go something like this:
Add the field
struct wait_queue *sleep;
to "struct mm_struct" in include/linux/sched.h. Add the code to initialize
it
init_waitqueue(&mm->sleep);
in mm_alloc() in kernel/fork.c, and then in kernel/fork.c: mmput() you'd
add a
wake_up(&mm->sleep);
at the top of the function.
Finally, add the following system call to arch/i386/kernel/process.c:
asmlinkage int sys_vfork(struct pt_regs regs)
{
/*
* This only works for a traditional process: don't
* try to do recursive vforks or mix clone and vfork.
*/
if (current->mm->count != 1)
return -EINVAL;
child = do_fork(CLONE_VM | SIGCHLD, regs.esp, ®s);
if (child > 0) {
while (current->mm->count > 1)
sleep_on(current->mm->sleep);
}
return child;
}
And you're done. Maybe. Apart from debugging the thing.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/