Two questions, related:
1) Is there a function that can return the protection of a given
memory page, akin to the way you can set the page's protection with
mprotect()?
2) When a SIGSEGV fault occurs I enter my own handler that I
installed using sigaction(). How do I obtain the type of operation
that caused the fault, e.g. say the page is PROT_NONE (no accesses
allowed) how can I tell if it was a read/write access that caused the
SIGSEGV?
Regards,
John
Not that I can think of.
mincore(2) can be useful to find out if a page is mapped (you don't
care if it's "in core" or not, but you look for ENOMEM to tell you
the address isn't mapped).
You can also read the memory mappings from /proc/self/map in Solaris
(and something equivalent on other unixs with /proc), find the
mapping containing the page of interest and extract the protection
from that. man -s 4 proc
--
Andrew Gabriel
Consultant Software Engineer