[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

munmap Subroutine

Purpose

Unmaps a mapped region.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <sys/mman.h>
int munmap (addrlen)
void *addr;
size_t len;

Description

The munmap subroutine unmaps a mapped file 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.

Parameters

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.

Return Values

When successful, the munmap subroutine returns 0. Otherwise, it returns -1 and sets the errno global variable to indicate the error.

Error Codes

If the munmap subroutine is unsuccessful, the errno global variable is set to the following value:

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 X/Open UNIX95 Specification compliant behavior and the len arguement is 0.

[ Previous | Next | Contents | Glossary | Home | Search ]