MPROTECT(2) BSD Programmer's Manual MPROTECT(2)NAMEmprotect - control the protection of pages
SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>
int
mprotect(void *addr, int len, int prot);
DESCRIPTION
The mprotect() system call changes the specified pages to have protection
prot. Not all implementations will guarantee protection on a page basis;
the granularity of protection changes may be as large as an entire re-
gion.
RETURN VALUES
Upon successful completion, mprotect() will return 0; otherwise a value
of -1 is returned and errno is set to indicate the error.
ERRORSMprotect() will fail and memory protection will remain unchanged if:
[EINVAL] Addr is not mapped or is not page-aligned.
[EINVAL] Len is negative or out of range.
[EACCES] The user does not have permission to weaken permissions to
prot.
SEE ALSOmsync(2), munmap(2), madvise(2), mincore(2)HISTORY
The mprotect() function first appeared in 4.4BSD.
BSDI BSD/OS October 21, 1997 1