Fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid
There is something about fork which I have never understood.  Maybe someone here can explain it to me.<p>Why would anyone ever want fork as a primitive?  It seems to me that what you really want is a combination of fork and exec because 99% of the time you immediately call exec after fork (at least that's what I do 99% of the time when I use fork).  If you <i>know</i> that you're going to call exec immediately after fork, then all the issues of dealing with the (potentially large) address space of the parent just evaporate because the child process is just going to immediately discard it all.<p>So why is there not a fork-exec combo?  And why has it not replaced fork for 99% of use cases?<p>And as long as I'm asking stupid questions, why would anyone ever use vfork?  If the child shares the parent's address space and uses the same stack as the parent, and the parent has to block, how is that different from a function call (other than being more expensive)?<p>None of this makes sense to me.