4 ms·
fork() by itself - inelegant. fork() - do ARBITRARY stuff in child process - exec(), now that does all kinds of things that a spawn()-type process creation can
by bediger 17y ago
fork() by itself - inelegant. fork() - do ARBITRARY stuff in child process - exec(), now that does all kinds of things that a spawn()-type process creation cannot do.
fork() allows the ability to do anything before exec(), setting up lighter-weight process creation, and whatever flexibility the programmer desires.
I'd turn it around: why do the designer's of spawn() or CreateProcess() think they've got the foresight to cover all of the bases for programmers? Why don't those systems do fork()/stuff/exec() to simplify?
- jacquesm 17y agoWhy is fork by itself inelegant ? Text editor, hit 'save', editor forks, saves in the background and quietly exits, no matter how long the save will take. Meanwhile the user continues to type in more text in the foreground. Just one example.
- makecheck 17y ago"fork() allows the ability to do anything before exec()..." That is not entirely true. See the "CAVEATS" section of "man fork".