The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

munmap - unmap pages of memory

 SYNOPSIS



#include <sys/mman.h>

int munmap(void *addr, size_t len);

 DESCRIPTION

The function munmap() removes any mappings for those entire pages containing any part of the address space of the process starting at addr and continuing for len bytes. Further references to these pages result in the generation of a SIGSEGV signal to the process. If there are no mappings in the specified address range, then munmap() has no effect.

The implementation  will require that addr be a multiple of the page size {PAGESIZE}.

If a mapping to be removed was private, any modifications made in this address range will be discarded.

Any memory locks (see mlock() and mlockall()) associated with this address range will be removed, as if by an appropriate call to munlock().

The behaviour of this function is unspecified if the mapping was not established by a call to mmap().

 RETURN VALUE

Upon successful completion, munmap() returns 0. Otherwise, it returns -1 and sets errno to indicate the error.

 ERRORS

The munmap() function will fail if:
[EINVAL]
Addresses in the range [addr, addr + len) are outside the valid range for the address space of a process.
[EINVAL]
The len argument is 0.
[EINVAL]
The addr argument is not a multiple of the page size as returned by sysconf().

 EXAMPLES

None.

 APPLICATION USAGE

The third form of EINVAL above is marked EX because it is defined as an optional error in the POSIX Realtime Extension.

 FUTURE DIRECTIONS

None.

 SEE ALSO

mmap(), sysconf(), <signal.h>, <sys/mman.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]