3 ms·
fork() fundamentally does not make sense as the de-facto method of starting a new process. Why aren't people using posix_spawn() by default?
by throwaway613834 9y ago
fork() fundamentally does not make sense as the de-facto method of starting a new process. Why aren't people using posix_spawn() by default?
- tedunangst 9y agoBecause that doesn't share memory.
- twic 9y agoYou can share memory in other ways, via mmap or SysV shared memory. You could imagine an implementation of the Ruby interpreter which kept all the expensive and shareable state (bytcode and class metadata, i suppose) in a shared memory segment, and used spawning to create worker processes with their own process heaps, but sharing that segment. It would be a lot of work to implement. It would probably be easier just to get Ruby to use threads properly.
- bpicolo 9y ago> bytcode and class metadata There's a bit more to it than that, as programs can run code and load data prefork. Pretty important for things like large config files.
- segmondy 9y agoimplementation of fork is defined by the POSIX standards. Apple should respect it. There are tons of apps that have been written using fork, are you going to change all of them to use posix_spawn()?
- deleted 9y ago[deleted]
- tedunangst 9y agoPosix standard says you can't call anything but async functions after fork() in a threaded program. Application developers should respect that.