> > Ok. When vfork() is called, save the stack pointer in the kernel.
> > Then, when the child calls exec(), more items are stored on the stack. (at
> > least the return address from the exec call)
> > When the parent is rescheduled, the system can reset the stack pointer
> > to the value it was when vfork was called, providing that it the child
> > never returned from the procedure that called fork, but instead called exec from
>there...
>
> The problem is that the child will pull data off the stack as it returns,
You could duplicate the return data on the stack for the child, or else use
an indirect jump to return in child process. You'd need to set the base
pointer correctly, so local variables are still accessable.
Because the data and stack are shared between parent and child, I'd expect
there are programs that expect changes to stack based variables made in the
child be reflected to the parent.
Eric