![]() |
![]() |
![]() |
Change memory protection
#include <sys/mman.h> int mprotect( const void * addr, size_t len, int prot );
libc
The mprotect() function changes the access protections on any mappings residing in the range starting at addr, and continuing for len bytes.
The prot parameter specifies the new access capabilities to the mapped memory region(s). The bits that can be combined in this field are defined in <sys/mman.h> and listed below:
![]() |
If mprotect() fails, the protections on some of the pages in the address range starting at addr and continuing for len bytes may have been changed. |
The memory object wasn't opened for write, and PROT_WRITE was specified for a MAP_SHARED type mapping.
The prot argument specifies PROT_WRITE on a MAP_PRIVATE mapping, and locking the private pages (if required) would need more space than the system can supply to reserve for doing so.
POSIX 1003.1 (Realtime Extensions)
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
errno, mmap(), munmap(), shm_open(), shm_unlink()
![]() |
![]() |
![]() |