dlclose Subroutine

Purpose

Closes and unloads a module loaded by the dlopen subroutine.

Syntax

#include <dlfcn.h>
int dlclose(Data);
void *Data;

Description

The dlclose subroutine is used to remove access to a module loaded with the dlopen subroutine. In addition, access to dependent modules of the module being unloaded is removed as well.

The dlclose subroutine performs C++ termination, like the terminateAndUnload subroutine does.

Modules being unloaded with the dlclose subroutine will not be removed from the process's address space if they are still required by other modules. Nevertheless, subsequent uses of Data are invalid, and further uses of symbols that were exported by the module being unloaded result in undefined behavior.

Parameters

Item Description
Data A loaded module reference returned from a previous call to dlopen.

Return Values

Upon successful completion, 0 (zero) is returned. Otherwise, errno is set to EINVAL, and the return value is also EINVAL. Even if the dlclose subroutine succeeds, the specified module may still be part of the process's address space if the module is still needed by other modules.

Error Codes

Item Description
EINVAL The Data parameter does not refer to a module opened by dlopen that is still open. The parameter may be corrupt or the module may have been unloaded by a previous call to dlclose.