, , , -, " ".
, ( , ) clone, :
pid_t new_vfork(void) {
return clone(child_func,
child_stack,
SIGCHLD | CLONE_VM,
NULL,
NULL,
NULL,
NULL);
}
, child_stack child_func , vfork, , child_func clone, child_stack (sys_clone) .
, sys_clone
pid_t new_vfork(void) {
return sys_clone( SIGCHLD | CLONE_VM, NULL);
}
, , , . NULL , child_stack, , vfork fork, , .
I have never used sys_clonedirectly or tested this, but I think it should work. I think that:
sys_clone( SIGCHLD | CLONE_VM | CLONE_VFORK, NULL);
equivalently vfork.
If this does not work (and you can not figure out how to make something like that), you can use a normal call clone with the challenges setjumpand longjmpto emulate it, or you can bypass the need for semantics "to return twice" forkand vfork.
source
share