Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory page protection

0 views
Skip to first unread message

John

unread,
May 9, 2003, 9:25:33 AM5/9/03
to
Hi,

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

Andrew Gabriel

unread,
May 9, 2003, 10:52:48 AM5/9/03
to
In article <935f4c48.03050...@posting.google.com>,

john....@cs.tcd.ie (John) writes:
> Hi,
>
> 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()?

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

0 new messages