8498 ficl: variable 'count' might be clobbered by 'longjmp' or 'vfork'
[unleashed.git] / share / man / man3c / dlclose.3c
blobc65eb03f8bd100fc37ff8d51a9bf334c2f18919c
1 '\" te
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"
7 .SH NAME
8 dlclose \- close a shared object
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <dlfcn.h>
14 \fBint\fR \fBdlclose\fR(\fBvoid *\fR\fIhandle\fR);
15 .fi
17 .SH DESCRIPTION
18 .sp
19 .LP
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.
26 .sp
27 .LP
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.
31 .SH RETURN VALUES
32 .sp
33 .LP
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.
38 .SH USAGE
39 .sp
40 .LP
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.
44 .SH ATTRIBUTES
45 .sp
46 .LP
47 See \fBattributes\fR(5) for descriptions of the following attributes:
48 .sp
50 .sp
51 .TS
52 box;
53 c | c
54 l | l .
55 ATTRIBUTE TYPE  ATTRIBUTE VALUE
57 Interface Stability     Standard
59 MT-Level        MT-Safe
60 .TE
62 .SH SEE ALSO
63 .sp
64 .LP
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)
68 .sp
69 .LP
70 \fILinker and Libraries Guide\fR
71 .SH NOTES
72 .sp
73 .LP
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.
79 .sp
80 .LP
81 Once an object has been closed by \fBdlclose()\fR, referencing symbols
82 contained in that object can cause undefined behavior.
83 .sp
84 .LP
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
93 \fBld.so.1\fR(1).