Safe Dynamic Library Execution and unload
i've to make an introduction of what am i doing before start making questions.
The goal of my work is to create an application quite like an IDE, for specific program development ( always in C++ ) and testing.
Since the need of execute these programs under the main IDE process for monitoring and logging purposes, my solution is to compile them as shared library and load them dynamically from the IDE. (Any suggestion about other strategies is welcome!)
The application is to be considered a 24h server, so can't be subject to problems like memory leaks or segmentation faults, neither be respawned by an external process.
As far as i know, segfaults may be handled intercepting the SIGSEGV signal, but this produces an undefined behavior.
So let's go with fun:
Question one: if the segfault is caused by a function in the shared library, loaded and executed in a separate thread, is possible to preserve the integrity of the running main process and handle the event without surprises?
Question two: since the thread share it's memory, how can i prevent memory leaks caused by the libraries after their unload?
I hope I explained well my need.
Thanks for the help!