← Back to context

Comment by boring_twenties

4 years ago

Splitting fork and exec allows you to do stuff before calling exec, for example redirecting file descriptors (like stdin/out/err), creating a pipe, modifying the child's environment, and so on.

These can all be made a part of the combined fork+exec API.

  • That would be the fugliest, most unwieldy API in history. In addition to the two most basic things I mentioned, there are namespaces, control groups, setuid/setgid, and probably a billion other things I can't think of.

    • Sure, just look at Win32 CreateProcessW.

      But that's the price you pay for an API that doesn't have footguns.