Using mprotect()

The mprotect() interface assigns the specified protection to all pages in the specified address range. The protection cannot exceed the permissions that are allowed on the underlying object. For more information, see the mprotect(2) man page.