I understand that shared objects can be effectively "reloaded" by calling dlclose() and just re-opening them, but can this be applied by an object to itself? Line 16 removes the old copy of object. However, if run on itself, it justifiably segfaults as I've told it to self-destruct with further code left to process. If I move the deletion to line 24 though, the object never seems to actually reload itself.
I can certainly add a check to prevent calling reload() on itself and move the deletion to line 24 and things work perfectly. Except that I'd like to be able to call reload() on itself if I can. Is there a way I'm overlooking? Or would a different set of dlopen() flags let me do this? Currently I open objects with RTLD_LAZY and RTLD_GLOBAL.
if ( client ) { if ( arg.empty() ) { client->Send( "Reload -which- command?" CRLF ); return; }
Line 16 removes the old copy of object. However, if run on itself, it justifiably segfaults as I've told it to self-destruct with further code left to process. If I move the deletion to line 24 though, the object never seems to actually reload itself.
I can certainly add a check to prevent calling reload() on itself and move the deletion to line 24 and things work perfectly. Except that I'd like to be able to call reload() on itself if I can. Is there a way I'm overlooking? Or would a different set of dlopen() flags let me do this? Currently I open objects with RTLD_LAZY and RTLD_GLOBAL.