DLL Programmer's Guide for TNS/E Systems

Dynamic Use of DLLs
DLL Programmer’s Guide for TNS/E Systems527252-006
3-7
Returned Values of dlclose
dlclose invalidates the handle and makes it unavailable for any other call that uses that
handle. If the specified handle is the last outstanding one for the referenced DLL and if
that DLL was dynamically loaded (by dlopen), the DLL is also unloaded. The following
is the parameter of a dlclose call:
dlopen_handle is a handle previously returned by a dlopen call.
Closing the last handle for the main program or for any DLLs that were loaded with the
main program does not unload any of these loadfiles. Also, if dlclose causes a loadfile
to be unloaded, then any DLL in its load set is also unloaded, unless that DLL also
belongs to the load set of the main program or to a DLL that still has an outstanding
handle for it. When dlclose unloads DLLs, the new operating load set becomes the old
operating load set less the unloaded DLLs.
Referencing code or data in a DLL using a handle that has been invalidated by dlclose
produces undefined results.
Issuing a dlopen that specifies a DLL previously unloaded by dlclose reloads that DLL
plus the libraries in its libList that are not already loaded, and establishes a new handle
to it.
Returned Values of dlclose
dlclose returns 0 if it successfully invalidated the specified handle.
Error-Return Values of dlclose
If dlclose cannot invalidate the specified handle, it returns a non-zero number. In that
event, call dlerror() for a textual description of that error, or dlresultcode() for
an encoded error code and error-detail.
Error Reporting For Dynamic Library Calls
(dlerror and dlresultcode)
Error Text : dlerror
To obtain information in textual form about any error that occurred in a dynamic library
call (dlopen, dlsym, or dlclose), a process can immediately invoke the following
function.
char *dlerror(void)
dlerror has no parameters.
The dlerror function returns 0 (a NULL pointer) if:
The immediately prior call to dlopen, dlclose, or dlsym had no error
dlerror has already been called since the last call to dlopen, dlclose, or dlsym