Unmaps pages of memory.
Standard C Library (libc.a)
The munmap subroutine unmaps a mapped file or shared memory region or anonymous memory region. The munmap subroutine unmaps regions created from calls to the mmap subroutine only.
If an address lies in a region that is unmapped by the munmap subroutine and that region is not subsequently mapped again, any reference to that address will result in the delivery of a SIGSEGV signal to the process.
Item | Description |
---|---|
addr | Specifies the address of the region to be unmapped. Must be a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter. |
len | Specifies the length, in bytes, of the region to be unmapped. If the len parameter is not a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter, the length of the region is rounded up to the next multiple of the page size. |
When successful, the munmap subroutine returns 0. Otherwise, it returns -1 and sets the errno global variable to indicate the error.
If the munmap subroutine is unsuccessful, the errno global variable is set to the following value:
Item | Description |
---|---|
EINVAL | The addr parameter is not a multiple of the page size as returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter. |
EINVAL | The application has requested Single UNIX Specification, Version 2 compliant behavior and the len arguement is 0. |