Fork() without exec() is dangerous in large programs
1–10 of 106 posts
Re: Fork() without exec() is dangerous in large programs
#2Re: Fork() without exec() is dangerous in large programs
#3In 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.
Re: Fork() without exec() is dangerous in large programs
#4In 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.
Re: Fork() without exec() is dangerous in large programs
#5In 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.
Applications can then instantiate their own threads and pass them to the library (i.e. dependency injection.)
So if you have 10 different concurrent libraries in an application, then you don't end up with 10 different threading paradigms or 10 different thread pools. This is a matter of application architecture -- libraries shouldn't bake in a specific policy.
Re: Fork() without exec() is dangerous in large programs
#6In 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 dunno--under that definition every concurrent GC is "dangerous".
When you are embedding a language like Go in a C program, its runtime becomes a library. But that's the example the proves the rule: there are (or were) well-known problems with that. Libraries shouldn't be doing GC.
Re: Fork() without exec() is dangerous in large programs
#7Typically calls such as malloc(), printf() etc. are strictly forbidden in the child after a fork().
Re: Fork() without exec() is dangerous in large programs
#8Here 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 basically can add 4th strategy -- fork once a small program at the start, then fork from there from then on.
Re: Fork() without exec() is dangerous in large programs
#9EDIT: Never mind, seems like initgroups() is also nonstandard but generally available on Unix-like systems.
Re: Fork() without exec() is dangerous in large programs
#10In 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.