I am not trying to handle the segmentation error. I understand how exception handling works, more or less. I would rather not make a mistake first. What I want to do is call a function or perform an operation that returns a value telling me whether a specific location / memory block is available or not, without actually accessing it and receiving an error.
That is, I would like the C function to check the address in Linux and / or Mac OS X before actually accessing it. Something like:
result = probe_memory(address,length)
where is the result
0 = writable 1 = read-only -1 = nonexistent
or something like that.
Is there anything similar on Linux and / or Mac OS X?
c segmentation-fault linux macos
user157426
source share