Comment by ncmncm
4 years ago
There should have been a fork+exec that would also do all the stuff everybody is obliged to code, anyway, between them.
Some programs would still fork, grovel around, and exec if the combined thing didn't do everything they need exactly the way they need, but the copying page tables and file descriptors, and marking everything read-only, is mostly wasted, as is the parent process needing to fault on all those pages. I wonder whether, if a COW page drops back to one reference, it is also marked back to writable, or if the fault has to happen anyway.
You're after posix_spawn(2) :D
I don't think i've ever seen posix_spawn(3) in a serious project. Maybe on a small embedded system lacking MMU support?
On Linux machines it is probably implemented with vfork + exec.
But the GP joke is (I guess) in suggesting by the "(2)" that it should be a system call, and not a library function that composes system calls.