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