Yap. Erlang 19 (latest version) switched to using a smaller spawner executable and spawns all OS processes from there by forking. So it forks something restricted and small not the whole VM. Here are the details of how it works: https://github.com/erlang/otp/blob/a5256e5221aff30f6d2cc7fab... They also claim a 3-5x speedup for launching external commands because of it. So there is a nice performance boost as well. So…
Fork() without exec() is dangerous in large programs
11–20 of 106 posts
Re: Fork() without exec() is dangerous in large programs
#12Re: Fork() without exec() is dangerous in large programs
#13In my opinion, it's libraries that secretly use threads under the covers (but still access state shared with the rest of the program like the malloc heap) that are what's dangerous.
This isn't an issue on non-UNIX OSes.
Re: Fork() without exec() is dangerous in large programs
#14fork() is not per se "dangerous" in such context. You just have to be careful enough and only use asynchronous-signal-safe fonctions, as you would do in a signal handler (see https://www.securecoding.cert.org/confluence/display/c/SIG30... ) Typically calls such as malloc(), printf() etc. are strictly forbidden in the child after a fork().
This post does the best job explaining the issue: http://www.linuxprogrammingblog.com/threads-and-fork-think-t...
Re: Fork() without exec() is dangerous in large programs
#15Re: Fork() without exec() is dangerous in large programs
#16In my opinion, it's libraries that secretly use threads under the covers (but still access state shared with the rest of the program like the malloc heap) that are what's dangerous.
I completely disagree. The only part of this that seems dangerous is the fact that it can turn a single-threaded program into a multi-threaded one, and the only real problem there is it makes fork-without-exec unsafe. But fork-without-exec is basically unsafe anyway unless you can absolutely guarantee that nothing has ever spawned a thread. Meanwhile, preventing libraries from using threading under the covers basical…
The thing is that any thread you launch is a big piece of machinery and your attempt to hide it is inevitably going to be a leaky abstraction.
Re: Fork() without exec() is dangerous in large programs
#17In my opinion, it's libraries that secretly use threads under the covers (but still access state shared with the rest of the program like the malloc heap) that are what's dangerous.
What is dangerous is that the interactions between threads and processes aren't part of POSIX standard and its behavior is OS specific across UNIX implementations. This isn't an issue on non-UNIX OSes.
Re: Fork() without exec() is dangerous in large programs
#18Face the fact, fork() is fundamentally flawed!
Re: Fork() without exec() is dangerous in large programs
#19Face the fact, fork() is fundamentally flawed!
I would like to see the reasons this comment was down-voted. It is true that fork(2) is simple and elegant design, but it involves a huge accidental complexity and hidden implications like in the original article. There is a reason that Linux has clone(2) underneath.
Re: Fork() without exec() is dangerous in large programs
#20Earlier quoted context omitted.
What is dangerous is that the interactions between threads and processes aren't part of POSIX standard and its behavior is OS specific across UNIX implementations. This isn't an issue on non-UNIX OSes.
How many non-unixes do have fork_without_exec()?
Hence why fork() is just kind-of implemented on their POSIX compatibility layers.
In UNIX it is only an issue, because IEEE doesn't want to set in stone in POSIX how threads, signals and processes should interact, due to the way threads were added to UNIX.