Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?



posix_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/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: