Question: what is mprotect used for?
Answer: mprotect (memory, page_size, PROT_READ); An advanced technique to monitor memory access is to protect the region of memory using mmap or mprotect and then handle the SIGSEGV signal that Linux sends to the program when it tries to access that memory.