mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 19:03:27 +00:00
Add real vfork logics
This commit is contained in:
committed by
Jianfeng Jiang
parent
43e43ca133
commit
e4f07b76a0
@ -195,8 +195,18 @@ pub fn clone_child(
|
||||
Ok(child_tid)
|
||||
} else {
|
||||
let child_process = clone_child_process(ctx, parent_context, clone_args)?;
|
||||
if clone_args.flags.contains(CloneFlags::CLONE_VFORK) {
|
||||
child_process.status().set_vfork_child(true);
|
||||
}
|
||||
|
||||
child_process.run();
|
||||
|
||||
if child_process.status().is_vfork_child() {
|
||||
let cond = || (!child_process.status().is_vfork_child()).then_some(());
|
||||
let current = ctx.process;
|
||||
current.children_wait_queue().wait_until(cond);
|
||||
}
|
||||
|
||||
let child_pid = child_process.pid();
|
||||
Ok(child_pid)
|
||||
}
|
||||
@ -435,8 +445,10 @@ fn clone_user_ctx(
|
||||
// The return value of child thread is zero
|
||||
child_context.set_syscall_ret(0);
|
||||
|
||||
if clone_flags.contains(CloneFlags::CLONE_VM) {
|
||||
// if parent and child shares the same address space, a new stack must be specified.
|
||||
if clone_flags.contains(CloneFlags::CLONE_VM) && !clone_flags.contains(CloneFlags::CLONE_VFORK)
|
||||
{
|
||||
// If parent and child shares the same address space and not in vfork situation,
|
||||
// a new stack must be specified.
|
||||
debug_assert!(new_sp != 0);
|
||||
}
|
||||
if new_sp != 0 {
|
||||
|
Reference in New Issue
Block a user