how can I detect whether a specific page is mapped in memory?
I would like to detect whether or not a specific page has already been mapped in memory. The goal here is to be able to perform this check before calling mmap with a fixed memory address. The following code illustrates what happens in this case by default: mmap silently remaps the original memory pages. #include <sys/mman.h> #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { int page_size; void *ptr; page_size = getpagesize(); ptr = mmap(0, 10 * page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); if (ptr == MAP_FAILED) { printf ("map1 failed\n");