1dlclose(3C)              Standard C Library Functions              dlclose(3C)
2
3
4

NAME

6       dlclose - close a shared object
7

SYNOPSIS

9       #include <dlfcn.h>
10
11       int dlclose(void *handle);
12
13

DESCRIPTION

15       The  dlclose()  function decrements the reference count of the supplied
16       handle. This handle represents an executable object file and its depen‐
17       dencies, acquired from a previous call to dlopen(). A handle that is no
18       longer referenced is processed in an attempt to unload any objects that
19       are  associated  with  the handle from the current process. An unrefer‐
20       enced handle is no longer available to dlsym().
21
22
23       Any finalization code within an object is executed prior to that object
24       being  unloaded.  Any routines registered by an object using atexit(3C)
25       are called prior to that object being unloaded. See NOTES.
26

RETURN VALUES

28       If the handle was successfully unreferenced, dlclose()  returns  0.  If
29       the handle is invalid, or an error occurred as a result of unloading an
30       object, dlclose()  returns  a  non-zero  value.  Additional  diagnostic
31       information is available through dlerror().
32

USAGE

34       The  dlclose()  function  is one of a family of functions that give the
35       user direct access to the dynamic linking facilities. These  facilities
36       are  available to dynamically-linked processes only. See the Linker and
37       Libraries Guide.
38

ATTRIBUTES

40       See attributes(5) for descriptions of the following attributes:
41
42
43
44
45       ┌─────────────────────────────┬─────────────────────────────┐
46       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
47       ├─────────────────────────────┼─────────────────────────────┤
48       │Interface Stability          │Standard                     │
49       ├─────────────────────────────┼─────────────────────────────┤
50       │MT-Level                     │MT-Safe                      │
51       └─────────────────────────────┴─────────────────────────────┘
52

SEE ALSO

54       ld(1), ld.so.1(1),  atexit(3C),  dladdr(3C),  dldump(3C),  dlerror(3C),
55       dlopen(3C), dlsym(3C), attributes(5), standards(5)
56
57
58       Linker and Libraries Guide
59

NOTES

61       A  successful  invocation  of   dlclose()  does  not guarantee that the
62       objects associated with the handle are removed from the  address  space
63       of  the current process. Objects can be referenced by multiple handles,
64       or by other objects. An object is not removed from the address space of
65       the current process until all references to that object are removed.
66
67
68       Once  an  object has been closed by dlclose(), referencing symbols con‐
69       tained in that object can cause undefined behavior.
70
71
72       As part of unloading an object, finalization code within the object  is
73       called  before  the  dlclose() returns. This finalization is user code,
74       and as such, can produce errors that can not be  caught  by  dlclose().
75       For  example,  an object loaded using RTLD_LAZY that attempts to call a
76       function that can not be located, results in process termination. Erro‐
77       neous  programming  practices  within  the  finalization  code can also
78       result in process termination. The runtime linkers  debugging  facility
79       can offer help identifying these types of error. See the LD_DEBUG envi‐
80       ronment variable of ld.so.1(1).
81
82
83
84SunOS 5.11                       1 March 2004                      dlclose(3C)
Impressum