> The clone(2) system call in linux allows for creation of child  
> processes that share address space with its parent, with the exception  
> of the stack segment. I believe that should do?

>Wouldn't the CLONE_VM flag do this?

no.

Linux shares the stack segment too: the underlying system call shares 
everything (given CLONE_VM),
and the clone library function simply switches the stack pointer to the address 
you give it,
but that's still in the shared address space.

rfork by contrast shares data and dss, but gives parent and child private 
[logical] copies of the stack.
that is, both initially have the same stack addresses and contents, but can 
subsequently change them
independently.  both stacks can grow.

clone therefore creates different memory contents for parent and child, with 
completely different
stack addresses and contents, and the code the child executes is distinguished 
by the clone call itself.

by contrast, rfork gives parent and child the same initial memory contents, 
sharing only the data,
and rfork's caller determines (based on the process ID return value) which does 
what after the call.


Reply via email to