How can I prevent (not react to) a segmentation fault?
I am not trying to handle a segmentation fault. I understand how exception
handling works, more or less. I would rather not have the fault in the
first place. What I want to do is call a function or perform an operation
that returns a value telling me whether or not that particular memory
location/block is accessible, without actually accessing it and getting
the fault.
That is, I would like a C function to probe an address in Linux and/or Mac
OS X before actually accessing it. Something like:
result = probe_memory(address,length)
where result is
0 = writable
1 = read-only
-1 = nonexistent
or something along those lines.
Is there anything like that in Linux and/or Mac OS X?
No comments:
Post a Comment