1MUNMAP(3P) POSIX Programmer's Manual MUNMAP(3P)
2
3
4
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
12 munmap — unmap pages of memory
13
15 #include <sys/mman.h>
16
17 int munmap(void *addr, size_t len);
18
20 The munmap() function shall remove any mappings for those entire pages
21 containing any part of the address space of the process starting at
22 addr and continuing for len bytes. Further references to these pages
23 shall result in the generation of a SIGSEGV signal to the process. If
24 there are no mappings in the specified address range, then munmap() has
25 no effect.
26
27 The implementation may require that addr be a multiple of the page size
28 as returned by sysconf().
29
30 If a mapping to be removed was private, any modifications made in this
31 address range shall be discarded.
32
33 Any memory locks (see mlock() and mlockall()) associated with this
34 address range shall be removed, as if by an appropriate call to
35 munlock().
36
37 If a mapping removed from a typed memory object causes the correspond‐
38 ing address range of the memory pool to be inaccessible by any process
39 in the system except through allocatable mappings (that is, mappings of
40 typed memory objects opened with the POSIX_TYPED_MEM_MAP_ALLOCATABLE
41 flag), then that range of the memory pool shall become deallocated and
42 may become available to satisfy future typed memory allocation
43 requests.
44
45 A mapping removed from a typed memory object opened with the
46 POSIX_TYPED_MEM_MAP_ALLOCATABLE flag shall not affect in any way the
47 availability of that typed memory for allocation.
48
49 The behavior of this function is unspecified if the mapping was not
50 established by a call to mmap().
51
53 Upon successful completion, munmap() shall return 0; otherwise, it
54 shall return -1 and set errno to indicate the error.
55
57 The munmap() function shall fail if:
58
59 EINVAL Addresses in the range [addr,addr+len) are outside the valid
60 range for the address space of a process.
61
62 EINVAL The len argument is 0.
63
64 The munmap() function may fail if:
65
66 EINVAL The addr argument is not a multiple of the page size as returned
67 by sysconf().
68
69 The following sections are informative.
70
72 None.
73
75 None.
76
78 The munmap() function corresponds to SVR4, just as the mmap() function
79 does.
80
81 It is possible that an application has applied process memory locking
82 to a region that contains shared memory. If this has occurred, the mun‐
83 map() call ignores those locks and, if necessary, causes those locks to
84 be removed.
85
86 Most implementations require that addr is a multiple of the page size
87 as returned by sysconf().
88
90 None.
91
93 mlock(), mlockall(), mmap(), posix_typed_mem_open(), sysconf()
94
95 The Base Definitions volume of POSIX.1‐2017, <sys_mman.h>
96
98 Portions of this text are reprinted and reproduced in electronic form
99 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
100 table Operating System Interface (POSIX), The Open Group Base Specifi‐
101 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
102 Electrical and Electronics Engineers, Inc and The Open Group. In the
103 event of any discrepancy between this version and the original IEEE and
104 The Open Group Standard, the original IEEE and The Open Group Standard
105 is the referee document. The original Standard can be obtained online
106 at http://www.opengroup.org/unix/online.html .
107
108 Any typographical or formatting errors that appear in this page are
109 most likely to have been introduced during the conversion of the source
110 files to man page format. To report such errors, see https://www.ker‐
111 nel.org/doc/man-pages/reporting_bugs.html .
112
113
114
115IEEE/The Open Group 2017 MUNMAP(3P)