[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    dlclose(3X) manual page Table of Contents

Name

dlclose - close a shared object

Synopsis

cc [ flag ... ] file ... -ldl [ library ... ]

#include <dlfcn.h>

int dlclose(void *handle);

MT-Level

MT-Safe

Description

dlclose() is one of a family of routines that give the user direct access to the dynamic linking facilities. (See ). These routines are made available via the library loaded when the option -ldl is passed to the link-editor.

These routines are available to dynamically linked processes ONLY.

dlclose() disassociates a shared object previously opened by dlopen() from the current process. Once an object has been closed using dlclose(), its symbols are no longer available to dlsym(). All objects loaded automatically as a result of invoking dlopen() on the referenced object are also closed. handle is the value returned by a previous invocation of dlopen().

Return Values

If the referenced object was successfully closed, dlclose() returns 0. If the object could not be closed, or if handle does not refer to an open object, dlclose() returns a non-0 value. More detailed diagnostic information will be available through dlerror().

See Also

ld(1) , dladdr(3X) , dlerror(3X) , dlopen(3X) , dlsym(3X)

Notes

A successful invocation of dlclose() does not guarantee that the objects associated with handle will actually be removed from the address space of the process. Objects loaded by one invocation of dlopen() may also be loaded by another invocation of dlopen(). The same object may also be opened multiple times. An object will not be removed from the address space until all references to that object through an explicit dlopen() invocation have been closed and all other objects implicitly referencing that object have also been closed.

Once an object has been closed by dlclose(), referencing symbols contained in that object can cause undefined behavior.


Table of Contents