munmap(3P4)
NAME
munmap − unmap a memory object
SYNOPSIS
#include <sys/mman.h>
int munmap(addr, len)
caddr_t addr;
size_t len;
DESCRIPTION
The function munmap removes a memory mapping for a given memory object. The addr specified must correspond to the beginning of a memory object which was previously mapped via the mmap(3P4) function. The value of len is ignored because the entire memory object will be unmapped. Further references to the pages which were previously mapped will result in the delivery of a SIGSEGV signal to the process.
The parameter addr is constrained to be segment-aligned (the address must be a multiple of SHMLBA, which is defined in /usr/include/sys/shm.h).
Any memory locks associated with this memory object will be removed.
RETURN VALUE
Upon successful completion, the function munmap returns a value of 0; otherwise, it returns a value of -1 and sets errno to indicate an error. Possible errors include:
[EINVAL] The value of addr is not segment-aligned. The addresses in the range starting at addr and continuing for len bytes do not correspond to a mapped memory object.
FILES
/usr/lib/libposix4.a
SEE ALSO
mmap(3P4), shm_open(3P4), shm_unlink(3P4), "CX/UX Programmer’s Guide"
BUGS
It is not possible to unmap a portion of a memory object. The entire memory object must be unmapped by munmap.
POSIX.4 states that the addr should be page-aligned according to the value returned by sysconf(2) for {_SC_PAGESIZE}. For this implementation, addr must be the exact address where the memory object is attached to the process - i.e., the address returned from mmap(3P4). In this sense, the addr parameter for munmap is governed by the rules for the addr parameter for mmap(3P4), including having to be segment-aligned.
WARNING
The interface to munmap is based on IEEE Draft Standard P1003.4/D12. This is an unapproved draft, subject to change. Use of information contained in this unapproved draft is at your own risk. This interface will change to reflect any changes made by future drafts of POSIX 1003.4.
CX/UX Programmer’s Reference Manual