Name
mprotect - set protection on a region of memory
Synopsis
#include <sys/mman.h>
int mprotect(void *addr, size_t len, int prot);
Description
mprotect() changes the access protections for the calling process’s memory pages containing any part of the address range in the interval [addr, addr+len-1].
addr must be aligned to a page boundary.
If the calling process tries to access memory in a manner that violates the protections, then the kernel generates a SIGSEGV signal for the process.
prot is either PROT_NONE, PROT_READ, PROT_WRITE, or PROT_READ | PROT_WRITE.
Return Value
On success, mprotect() returns zero. On error, it returns -1, and errno is set appropriately.