dlopen()/dlsym()/dlerror() was: Re: libXcursor.so.1.0.2 reference in libX11.so.6 ??

Rob spamrefuse at yahoo.com
Mon Oct 31 05:39:23 PST 2005


--- Igor Robul <igorr at speechpro.com> wrote:

> Rob wrote:
> >However, the last successful dlopen call does NOT
> >clear the earlier dlerror indicator.
>
> dlerror() resets error indicator. From
> /usr/src/libexec/rtld-elf/rtld.c:
>
> Error indicator is not reset by successful call to
> dlopen(), but I'm not sure that dlopen() need reset
> error indicator. At least I could not find
> information about this in manual page.

Noone seems to be sure on what a successful dlopen
should do with a previous set dlerror indicator.
On some OSes it clears the error (and those people
may then assume it should do that in all OSes),
whereas it does not so on FreeBSD.
Posix may have defined a standard, but I have no
access to the Posix guidelines; neither am I
interested, since by now my problem with Grace is
resolved :).

> Is there any standard which describes dl*()
> functions?

As I said, maybe Posix does ?

> Because from _my_ point of view
> dlopen()/dlsym() need not clear error indicator on
> success, dlopen()/dlsym() need to return NULL on
> error.

dlopen() indeed returns NULL on error, but dlsym()
may return NULL, without experiencing any error;
if dlsym() encounters an error, then it will return
NULL *AND* sets the dlerror. E.g. this is what you
supposed to code:

   data = dlsym(....);
   error = dlerror();
   if ( !data && error != NULL ) {
        print_error(error);
        return FAILURE;
   }


> dlerror() is one who can/have to clear error
> indicator.

Yes, sure, dlerror() clears previous dlerror
indicator.

Rob.



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs


More information about the freebsd-questions mailing list