3 ms·
> If you want to spawn a new process on Darwin you really want to reach for posix_spawn Assuming you can avoid the bugs and version-sensitivities. There are a
by o11c 2y ago
> If you want to spawn a new process on Darwin you really want to reach for posix_spawn
Assuming you can avoid the bugs and version-sensitivities. There are a lot of them on various platforms, and my gut says they're more prominent on Darwin since alternatives are unrecommended.
The dup2/cloexec mess is the one that sticks in my mind but it's far from the only one.
- manwe150 2y agonodejs (via libuv) transparently switches from fork to pthread_spawn on Darwin when the options passed support it. The dup2/cloexec is a mess, but there are some Darwin-specific enhancements to work around it. There is work done to make it also do the same on Linux, but seems it hasn’t been merged yet. The reason glibc uses clone is that it can specify an extra flag to avoid some undefined behavior inherent in the way vfork was originally designed, so it can get all of the equivalent speed with none of the pointy edges