MPROTECT(2) System Calls Manual MPROTECT(2)
mprotect - set protection of memory mapping
mprotect(addr, len, prot)
int len, prot;
mprotect() changes the access protections on the mappings specified by
the range [addr, addr + len) to be that specified by prot. Legitimate
values for prot are the same as those permitted for mmap(2).
0 on success.
-1 on failure and sets errno to indicate the error.
EACCES prot specifies a protection which violates the access
permission the process has to the underlying memory
EINVAL addr is not a multiple of the page size as returned by
ENOMEM Addresses in the range [addr, addr + len) are invalid
for the address space of a process, or specify one or
more pages which are not mapped.
When mprotect() fails for reasons other than EINVAL, the protections on
some of the pages in the range [addr, addr + len) will have been
changed. If the error occurs on some page at address addr2, then the
protections of all whole pages in the range [addr, addr2) have been
21 January 1990 MPROTECT(2)