Seems to me it is so general question I wanted to ask on Computer Science site but could not find proper tags, so asking here. Mods please move if appropriate.

As I've read in many places, e.g. here What's the difference between eval and exec? to run a program parent process in Linux forks (copies all info) itself then replaces in that fork itself by calling exec with needed program.

Why not just make/start a new process? How is it better (as it was implemented that way, looks like it is better by some criteria)?

I could not find an answer by web search for Linux: why to execute a program first we need to copy (fork) current one? and here on SE questions on exec fork are about technical details, not why type.

  • I've read on one Q&A long ago that this was done for efficiency. Starting new process at the time of the first Unix was expensive in terms of resources, RAM and CPU cycles. Cloning and replacing process via exec was easier. Of course nowadays it's not necessary on regular desktop or server but on something embedded like router or Raspberry Pi that still helps. So you could say historical reasons is one reason Sep 27 '19 at 4:47
  • Let me know if you dont get a good answer. I'll try to look up that Q&A I mentioned in my previous comment. Sep 27 '19 at 4:48
  • 1
    I think it's this one unix.stackexchange.com/q/136637/85039 Maybe even fits as duplicate Sep 27 '19 at 4:50
  • @Sergiy Kolodyazhnyy, thank you, looks like duplicate, I don't see in my GUI way to mark it as one.
    – Marisha
    Sep 27 '19 at 4:52
  • Ok, I marked it, so there will need to be 3 more votes to support it. Glad I could help you find the answer Sep 27 '19 at 4:54

Browse other questions tagged or ask your own question.