2 .\" Copyright 1989 AT&T Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH DLCLOSE 3C "Mar 1, 2004"
8 dlclose \- close a shared object
14 \fBint\fR \fBdlclose\fR(\fBvoid *\fR\fIhandle\fR);
20 The \fBdlclose()\fR function decrements the reference count of the supplied
21 \fIhandle\fR. This \fIhandle\fR represents an executable object file and its
22 dependencies, acquired from a previous call to \fBdlopen()\fR. A \fIhandle\fR
23 that is no longer referenced is processed in an attempt to unload any objects
24 that are associated with the \fIhandle\fR from the current process. An
25 unreferenced \fIhandle\fR is no longer available to \fBdlsym()\fR.
28 Any finalization code within an object is executed prior to that object being
29 unloaded. Any routines registered by an object using \fBatexit\fR(3C) are
30 called prior to that object being unloaded. See NOTES.
34 If the \fIhandle\fR was successfully unreferenced, \fBdlclose()\fR returns
35 \fB0\fR. If the \fIhandle\fR is invalid, or an error occurred as a result of
36 unloading an object, \fBdlclose()\fR returns a non-zero value. Additional
37 diagnostic information is available through \fBdlerror()\fR.
41 The \fBdlclose()\fR function is one of a family of functions that give the user
42 direct access to the dynamic linking facilities. These facilities are available
43 to dynamically-linked processes only. See the \fILinker and Libraries Guide\fR.
47 See \fBattributes\fR(5) for descriptions of the following attributes:
55 ATTRIBUTE TYPE ATTRIBUTE VALUE
57 Interface Stability Standard
65 \fBld\fR(1), \fBld.so.1\fR(1), \fBatexit\fR(3C), \fBdladdr\fR(3C),
66 \fBdldump\fR(3C), \fBdlerror\fR(3C), \fBdlopen\fR(3C), \fBdlsym\fR(3C),
67 \fBattributes\fR(5), \fBstandards\fR(5)
70 \fILinker and Libraries Guide\fR
74 A successful invocation of \fBdlclose()\fR does not guarantee that the objects
75 associated with the \fIhandle\fR are removed from the address space of the
76 current process. Objects can be referenced by multiple \fIhandles\fR, or by
77 other objects. An object is not removed from the address space of the current
78 process until all references to that object are removed.
81 Once an object has been closed by \fBdlclose()\fR, referencing symbols
82 contained in that object can cause undefined behavior.
85 As part of unloading an object, finalization code within the object is called
86 \fBbefore\fR the \fBdlclose()\fR returns. This finalization is user code, and
87 as such, can produce errors that can not be caught by \fBdlclose()\fR. For
88 example, an object loaded using \fBRTLD_LAZY\fR that attempts to call a
89 function that can not be located, results in process termination. Erroneous
90 programming practices within the finalization code can also result in process
91 termination. The runtime linkers debugging facility can offer help identifying
92 these types of error. See the \fBLD_DEBUG\fR environment variable of