munmap

Unmaps a mapped region.

Format

#include  <mman.h>

int munmap  (void *addr, size_t len);

Arguments

addr
The address of the region that you want to unmap.
len
The length in bytes of that region the you want to unmap.

Description

This function unmaps a mapped file or shared memory region.

The addr and len arguments specify the address and length in bytes, respectively, of the region to be unmapped.

The len argument must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE); otherwise, the length of the region is rounded up to the next multiple of the page size.

The result of using an address that lies in an unmapped region and not in any subsequently mapped region is undefined.

See also sysconf in this section.

Return Values
Indicates success. 
-1  Indicates an error; errno is set to one of the following values:

  • ENIVAL - The addr argument is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).

  • EFAULT - The range [addr, addr + len] includes an invalid address.
 


Previous Page | Next Page | Table of Contents | Index