3 ms·
You don't HAVE to use fork() + exec() in Linux as far as I know. There is for example posix_swawn() which does the double whammy combo for you. Also, if you DO
by 0x0 4y ago
You don't HAVE to use fork() + exec() in Linux as far as I know. There is for example posix_swawn() which does the double whammy combo for you.
Also, if you DO use fork() without immediately doing an exec(), and start writing all over your existing allocations... just don't?
- the8472 4y agoposix_spawn isn't powerful enough since it only supports a limited set of process setup operations. So if you need to do some specific syscalls before exec that aren't covered by it then the fork/exec dance is still necessary. In principle one can use vfork+exec instead but that very hard to get right. What's really needed is io_uring_spawn but that's still a WIP. https://lwn.net/Articles/908268/ https://lwn.net/Articles/908268/