Unix Programming - dlclose and RTLD_GLOBAL

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2007 > dlclose and RTLD_GLOBAL





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author dlclose and RTLD_GLOBAL
Diego Santos

2007-03-28, 1:18 pm

Hi,
I have created an application that uses shared libs (plugins). I need
to load and unload the libs at run time.
I need to open the shared libs with RTLD_GLOBAL parameter and I open
all shared libs without any problems. But when I try to unload the
libs (dlclose), my application crashs (segmentation fault). If I dont
use RTLD_GLOBAL, all works fine.

Here are a piece of my code that loads the libs:

while ( (temp=man->getActiveNameFromFile())!=NULL)
{
void *dlib;

dlib = dlopen(temp,RTLD_NOW|RTLD_GLOBAL);
liblist.push_back(dlib);
if (dlib == NULL)
{
fl_alert(dlerror());
}
}


Note that I put all handles (void *) in a std::list. The dlopen
works fine, all libs are loaded.
Then, I try to unload all libs as the following:

std::list<void *>::iterator it;

for (it=liblist.begin(); it!=liblist.end(); it++)
if (dlclose(*it))
printf("\nErro\n");

But the applications always crash here.

I have tried to use dlclose in reverse order too without success.

Please, can anyone help me?

I'd like to load and unload the shared libs dynamically, but I
couldn't unload it.

Thanks in advance,

Diego

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com