Kernel allocates a new process stack during vfork(). We should reuse the parent stack instead (child->sp = parent->sp at the time of the vfork()), child will push/pop new stackframes, but won't pop any stackframes pushed by the parent because child cannot return from function calling vfork(). The child cannot return from the function calling vfork(), and also cannot modify any other variables than the vfork() return code.
"Modify" means it still can read parent's variable => GP registers must be copied
Stack will be handed back to parent when child exits, and parent wake up
From Linux man page:
vfork() differs from fork(2) in that the calling thread is suspended
until the child terminates (either normally, by calling _exit(2), or
abnormally, after delivery of a fatal signal), or it makes a call to
execve(2). Until that point, the child shares all memory with its
parent, including the stack. The child must not return from the
current function or call exit(3) (which would have the effect of
calling exit handlers established by the parent process and flushing
the parent's stdio(3) buffers), but may call _exit(2).
Kernel allocates a new process stack during vfork(). We should reuse the parent stack instead (child->sp = parent->sp at the time of the vfork()), child will push/pop new stackframes, but won't pop any stackframes pushed by the parent because child cannot return from function calling vfork(). The child cannot return from the function calling vfork(), and also cannot modify any other variables than the vfork() return code.
From Linux man page:
http://man7.org/linux/man-pages/man2/vfork.2.html