'\" te .\" Copyright 1989 AT&T Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH DLCLOSE 3C "Mar 1, 2004" .SH NAME dlclose \- close a shared object .SH SYNOPSIS .LP .nf #include \fBint\fR \fBdlclose\fR(\fBvoid *\fR\fIhandle\fR); .fi .SH DESCRIPTION .sp .LP The \fBdlclose()\fR function decrements the reference count of the supplied \fIhandle\fR. This \fIhandle\fR represents an executable object file and its dependencies, acquired from a previous call to \fBdlopen()\fR. A \fIhandle\fR that is no longer referenced is processed in an attempt to unload any objects that are associated with the \fIhandle\fR from the current process. An unreferenced \fIhandle\fR is no longer available to \fBdlsym()\fR. .sp .LP Any finalization code within an object is executed prior to that object being unloaded. Any routines registered by an object using \fBatexit\fR(3C) are called prior to that object being unloaded. See NOTES. .SH RETURN VALUES .sp .LP If the \fIhandle\fR was successfully unreferenced, \fBdlclose()\fR returns \fB0\fR. If the \fIhandle\fR is invalid, or an error occurred as a result of unloading an object, \fBdlclose()\fR returns a non-zero value. Additional diagnostic information is available through \fBdlerror()\fR. .SH USAGE .sp .LP The \fBdlclose()\fR 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 \fILinker and Libraries Guide\fR. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Standard _ MT-Level MT-Safe .TE .SH SEE ALSO .sp .LP \fBld\fR(1), \fBld.so.1\fR(1), \fBatexit\fR(3C), \fBdladdr\fR(3C), \fBdldump\fR(3C), \fBdlerror\fR(3C), \fBdlopen\fR(3C), \fBdlsym\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5) .sp .LP \fILinker and Libraries Guide\fR .SH NOTES .sp .LP A successful invocation of \fBdlclose()\fR does not guarantee that the objects associated with the \fIhandle\fR are removed from the address space of the current process. Objects can be referenced by multiple \fIhandles\fR, 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. .sp .LP Once an object has been closed by \fBdlclose()\fR, referencing symbols contained in that object can cause undefined behavior. .sp .LP As part of unloading an object, finalization code within the object is called \fBbefore\fR the \fBdlclose()\fR returns. This finalization is user code, and as such, can produce errors that can not be caught by \fBdlclose()\fR. For example, an object loaded using \fBRTLD_LAZY\fR 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 \fBLD_DEBUG\fR environment variable of \fBld.so.1\fR(1).