I am writing a network application in C ++ and I want to enable the creation of plugins, but I do not know what to do to protect my application from errors like segfault. For example: I have an interface:
class IPlugin{
public:
IPlugin();
virtual ~IPlugin();
virtual void callPlugin() = 0;
}
And someone will write a dynamic library:
class Plugin : public IPlugin{
public:
Plugin();
virtual ~Plugin();
virtual void callPlugin();
}
void Plugin::callPlugin(){
int* a = NULL;
*a = 5;
}
The call to this function in my application will end with the completion of everything. I know that I can use fork (), but the functions in the plugins will be short and will be used many times, so I think fork () is too slow. Any ideas?
PS. And sorry for my english.
source
share