3 ms·
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 th
by boring_twenties 5y 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.
- loeg 5y ago(This is particularly useful for shells.)
- int_19h 5y agoThese can all be made a part of the combined fork+exec API.
- boring_twenties 5y agoThat 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.
- int_19h 5y agoSure, just look at Win32 CreateProcessW. But that's the price you pay for an API that doesn't have footguns.