1DLCLOSE(3P)                POSIX Programmer's Manual               DLCLOSE(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       dlclose - close a dlopen object
13

SYNOPSIS

15       #include <dlfcn.h>
16
17       int dlclose(void *handle);
18
19

DESCRIPTION

21       The dlclose() function shall inform the system that the  object  refer‐
22       enced  by  a  handle returned from a previous dlopen() invocation is no
23       longer needed by the application.
24
25       The use of dlclose() reflects a statement of intent on the part of  the
26       process,  but  does not create any requirement upon the implementation,
27       such as removal of the code or symbols referenced by  handle.  Once  an
28       object  has  been  closed  using dlclose() an application should assume
29       that its symbols are no longer available to dlsym(). All objects loaded
30       automatically as a result of invoking dlopen() on the referenced object
31       shall also be closed if this is the last reference to it.
32
33       Although a dlclose() operation is not  required  to  remove  structures
34       from  an  address  space,  neither is an implementation prohibited from
35       doing so. The only restriction on such a  removal  is  that  no  object
36       shall  be  removed  to  which  references have been relocated, until or
37       unless all such references are removed. For instance,  an  object  that
38       had  been  loaded  with a dlopen() operation specifying the RTLD_GLOBAL
39       flag might provide a target for dynamic relocations  performed  in  the
40       processing  of  other  objects-in such environments, an application may
41       assume that no relocation, once made, shall be undone or remade  unless
42       the object requiring the relocation has itself been removed.
43

RETURN VALUE

45       If  the  referenced  object  was  successfully  closed, dlclose() shall
46       return 0. If the object could not be closed,  or  if  handle  does  not
47       refer  to an open object, dlclose() shall return a non-zero value. More
48       detailed diagnostic information shall be available through dlerror().
49

ERRORS

51       No errors are defined.
52
53       The following sections are informative.
54

EXAMPLES

56       The following example illustrates use of dlopen() and dlclose():
57
58
59              ...
60              /* Open a dynamic library and then close it ... */
61
62
63              #include <dlfcn.h>
64              void *mylib;
65              int eret;
66
67
68              mylib = dlopen("mylib.so", RTLD_LOCAL | RTLD_LAZY);
69              ...
70              eret = dlclose(mylib);
71              ...
72

APPLICATION USAGE

74       A conforming  application  should  employ  a  handle  returned  from  a
75       dlopen() invocation only within a given scope bracketed by the dlopen()
76       and dlclose() operations. Implementations are  free  to  use  reference
77       counting  or other techniques such that multiple calls to dlopen() ref‐
78       erencing the same object may return the same object for handle.  Imple‐
79       mentations  are  also  free  to  reuse a handle. For these reasons, the
80       value of a handle must be treated as an opaque object by  the  applica‐
81       tion, used only in calls to dlsym() and dlclose().
82

RATIONALE

84       None.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       dlerror(),   dlopen(),   dlsym(),   the   Base  Definitions  volume  of
91       IEEE Std 1003.1-2001, <dlfcn.h>
92
94       Portions of this text are reprinted and reproduced in  electronic  form
95       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
96       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
97       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
98       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
99       event of any discrepancy between this version and the original IEEE and
100       The Open Group Standard, the original IEEE and The Open Group  Standard
101       is  the  referee document. The original Standard can be obtained online
102       at http://www.opengroup.org/unix/online.html .
103
104
105
106IEEE/The Open Group                  2003                          DLCLOSE(3P)
Impressum