1MUNMAP(3P)                 POSIX Programmer's Manual                MUNMAP(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       munmap - unmap pages of memory
13

SYNOPSIS

15       #include <sys/mman.h>
16
17       int munmap(void *addr, size_t len);
18
19

DESCRIPTION

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  shall  require that addr be a multiple of the page
29       size {PAGESIZE}.
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

RETURN VALUE

54       Upon successful completion, munmap()  shall  return  0;  otherwise,  it
55       shall return -1 and set errno to indicate the error.
56

ERRORS

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       EINVAL The addr argument is not a multiple of the page size as returned
66              by sysconf().
67
68
69       The following sections are informative.
70

EXAMPLES

72       None.
73

APPLICATION USAGE

75       The  munmap()  function  is  only  supported if the Memory Mapped Files
76       option or the Shared Memory Objects option is supported.
77

RATIONALE

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

FUTURE DIRECTIONS

88       None.
89

SEE ALSO

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