Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dlclose(3c) [opensolaris man page]

dlclose(3C)						   Standard C Library Functions 					       dlclose(3C)

NAME
dlclose - close a shared object SYNOPSIS
#include <dlfcn.h> int dlclose(void *handle); DESCRIPTION
The dlclose() function decrements the reference count of the supplied handle. This handle represents an executable object file and its dependencies, acquired from a previous call to dlopen(). A handle that is no longer referenced is processed in an attempt to unload any objects that are associated with the handle from the current process. An unreferenced handle is no longer available to dlsym(). Any finalization code within an object is executed prior to that object being unloaded. Any routines registered by an object using atexit(3C) are called prior to that object being unloaded. See NOTES. RETURN VALUES
If the handle was successfully unreferenced, dlclose() returns 0. If the handle is invalid, or an error occurred as a result of unloading an object, dlclose() returns a non-zero value. Additional diagnostic information is available through dlerror(). USAGE
The dlclose() function is one of a family of functions that give the user direct access to the dynamic linking facilities. These facilities are available to dynamically-linked processes only. See the Linker and Libraries Guide. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
ld(1), ld.so.1(1), atexit(3C), dladdr(3C), dldump(3C), dlerror(3C), dlopen(3C), dlsym(3C), attributes(5), standards(5) Linker and Libraries Guide NOTES
A successful invocation of dlclose() does not guarantee that the objects associated with the handle are removed from the address space of the current process. Objects can be referenced by multiple handles, or by other objects. An object is not removed from the address space of the current process until all references to that object are removed. Once an object has been closed by dlclose(), referencing symbols contained in that object can cause undefined behavior. As part of unloading an object, finalization code within the object is called before the dlclose() returns. This finalization is user code, and as such, can produce errors that can not be caught by dlclose(). For example, an object loaded using RTLD_LAZY that attempts to call a function that can not be located, results in process termination. Erroneous programming practices within the finalization code can also result in process termination. The runtime linkers debugging facility can offer help identifying these types of error. See the LD_DEBUG environment variable of ld.so.1(1). SunOS 5.11 1 March 2004 dlclose(3C)

Check Out this Related Man Page

atexit(3C)						   Standard C Library Functions 						atexit(3C)

NAME
atexit - register a function to run at process termination or object unloading SYNOPSIS
#include <stdlib.h> int atexit(void (*func)(void)); DESCRIPTION
The atexit() function registers the function pointed to by func to be called without arguments on normal termination of the program or when the object defining the function is unloaded. Normal termination occurs by either a call to the exit(3C) function or a return from main(). Object unloading occurs when a call to dlclose(3C) results in the object becoming unreferenced. The number of functions that may be registered with atexit() is limited only by available memory (refer to the _SC_ATEXIT_MAX argument of sysconf(3C)). After a successful call to any of the exec(2) functions, any functions previously registered by atexit() are no longer registered. On process exit, functions are called in the reverse order of their registration. On object unloading, any functions belonging to an unloadable object are called in the reverse order of their registration. RETURN VALUES
Upon successful completion, the atexit() function returns 0. Otherwise, it returns a non-zero value. ERRORS
The atexit() function may fail if: ENOMEM Insufficient storage space is available. USAGE
The functions registered by a call to atexit() must return to ensure that all registered functions are called. There is no way for an application to tell how many functions have already been registered with atexit(). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
exec(2), dlclose(3C), exit(3C), sysconf(3C), attributes(5) SunOS 5.11 25 May 2001 atexit(3C)
Man Page