📄 dlclose.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>dlclose</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="dlclose"></a> <a name="tag_03_109"></a><!-- dlclose --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_109_01"></a>NAME</h4><blockquote>dlclose - close a dlopen object</blockquote><h4><a name="tag_03_109_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include <<a href="../basedefs/dlfcn.h.html">dlfcn.h</a>><br><br> int dlclose(void *</tt><i>handle</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_109_03"></a>DESCRIPTION</h4><blockquote><p>The <i>dlclose</i>() function shall inform the system that the object referenced by a <i>handle</i> returned from a previous <ahref="../functions/dlopen.html"><i>dlopen</i>()</a> invocation is no longer needed by the application.</p><p>The use of <i>dlclose</i>() reflects a statement of intent on the part of the process, but does not create any requirement uponthe implementation, such as removal of the code or symbols referenced by <i>handle</i>. Once an object has been closed using<i>dlclose</i>() an application should assume that its symbols are no longer available to <a href="../functions/dlsym.html"><i>dlsym</i>()</a>. All objects loaded automatically as a result of invoking <a href="../functions/dlopen.html"><i>dlopen</i>()</a> on the referenced object shall also be closed if this is the last reference toit.</p><p>Although a <i>dlclose</i>() operation is not required to remove structures from an address space, neither is an implementationprohibited from doing so. The only restriction on such a removal is that no object shall be removed to which references have beenrelocated, until or unless all such references are removed. For instance, an object that had been loaded with a <a href="../functions/dlopen.html"><i>dlopen</i>()</a> operation specifying the RTLD_GLOBAL flag might provide a target for dynamicrelocations performed in the processing of other objects-in such environments, an application may assume that no relocation, oncemade, shall be undone or remade unless the object requiring the relocation has itself been removed.</p></blockquote><h4><a name="tag_03_109_04"></a>RETURN VALUE</h4><blockquote><p>If the referenced object was successfully closed, <i>dlclose</i>() shall return 0. If the object could not be closed, or if<i>handle</i> does not refer to an open object, <i>dlclose</i>() shall return a non-zero value. More detailed diagnosticinformation shall be available through <a href="../functions/dlerror.html"><i>dlerror</i>()</a>.</p></blockquote><h4><a name="tag_03_109_05"></a>ERRORS</h4><blockquote><p>No errors are defined.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_109_06"></a>EXAMPLES</h4><blockquote><p>The following example illustrates use of <a href="../functions/dlopen.html"><i>dlopen</i>()</a> and <i>dlclose</i>():</p><pre><tt>.../* Open a dynamic library and then close it ... */<br>#include <dlfcn.h>void *mylib;int eret;<br>mylib = dlopen("mylib.so", RTLD_LOCAL | RTLD_LAZY);...eret = dlclose(mylib);...</tt></pre></blockquote><h4><a name="tag_03_109_07"></a>APPLICATION USAGE</h4><blockquote><p>A conforming application should employ a <i>handle</i> returned from a <a href="../functions/dlopen.html"><i>dlopen</i>()</a>invocation only within a given scope bracketed by the <a href="../functions/dlopen.html"><i>dlopen</i>()</a> and <i>dlclose</i>()operations. Implementations are free to use reference counting or other techniques such that multiple calls to <a href="../functions/dlopen.html"><i>dlopen</i>()</a> referencing the same object may return the same object for <i>handle</i>.Implementations are also free to reuse a <i>handle</i>. For these reasons, the value of a <i>handle</i> must be treated as anopaque object by the application, used only in calls to <a href="../functions/dlsym.html"><i>dlsym</i>()</a> and<i>dlclose</i>().</p></blockquote><h4><a name="tag_03_109_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_109_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_109_10"></a>SEE ALSO</h4><blockquote><p><a href="dlerror.html"><i>dlerror</i>()</a> , <a href="dlopen.html"><i>dlopen</i>()</a> , <a href="dlsym.html"><i>dlsym</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/dlfcn.h.html"><i><dlfcn.h></i></a></p></blockquote><h4><a name="tag_03_109_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 5.</p></blockquote><h4><a name="tag_03_109_12"></a>Issue 6</h4><blockquote><p>The DESCRIPTION is updated to say that the referenced object is closed "if this is the last reference to it".</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -