Fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid
Hard disagree to most of this.<p>fork(2) makes a lot more sense when you realize its heritage.  It came from a land before Unix supported full MMUs.  In this model, to still have per process address spaces and preemptive multitasking on what was essentially a PC-DOS level of hardware, the kernel would checkpoint the memory for a process, slurp it all out to dectape or some such, and load in the memory for whatever the scheduler wanted to run next.  It&#x27;s simplicity of being process checkpoint based wasn&#x27;t a reaction to windows style calls (which wouldn&#x27;t exist for almost a couple decades), but instead mainframe process spawning abominations like JCL.  The idea &quot;you probably want most of what you have so force a checkpoint, copy the checkpoint into a new slot, and continue separately from both checkpoints&quot; was soooo much better than JCL and it&#x27;s tomes of incantations to do just about anything.<p>vfork(2) is an abomination.  Even when the child returns, the parent now has a heavily modified stack if the child didn&#x27;t immediately exec().  All of those bugs that causes are super fun to chase, lemme tell you.  AFAIC, about the only valid use for vfork now is nommu systems where fork() incredibly expensive compared to what is generally expected.<p>clone(2) is great.  Start from a checkpoint like fork, but instead of semantically copying everything, optionally share or not based on a bitmask.  Share a tgid, virtual address space, and FD table?  You just made a thread.  Share nothing?  You just made a process.  It&#x27;s the most &#x27;mechanism, not policy&#x27; way I&#x27;ve seen to do context creation outside of maybe the l4 variants and the exokernels.  This isn&#x27;t an old holdover, this is how threads work today, processes spawned that happen to share resources.  Modern archs on linux don&#x27;t even have a fork(2) syscall; it all happens through clone(2).  Even vfork is clone set to share virtual address space and nothing else that fork wouldn&#x27;t share.  Namespaces are a way to opt into not sharing resources that normally fork <i>would</i> share.<p>And I don&#x27;t see what afork gets you that clone doesn&#x27;t, except afork isn&#x27;t as general.