I'm working on a small project and I'm looking for advice.
Basically, I have a main process that is a server with a variety of dynamically growing data structures and some sockets here and there.
In some cases I need to create processes that run a small loop as long as necessary (they don't need any data structure, fd or socket of the main server). An important requirement is that they should be: fast, light and durable (even if the main server killed).
fork: I get durability over time but copying the main server means to copy all its data structures, fd etc. that would weigh down the new process unnecessarily.
thread: light and fast but not durable and above all very unstable (if a thread for some reason generates an error could block everything).
The ideal thing would be a magic system call, that executes an ex novo process that has a function as entry point but I think there is nothing like that.
Do you have any advice for me?