Memory Fault Prevent

I’ve got a system with no video output. as output I have only two leds, one is power, the other check the state of the system. If during the initial P-Bit, some error loading the boars/hdd/etc is found, the led is setted to red, otherwise, the led is green and the main program is started.
if the main program fail in some expected way, I stop any program activity and I set the led to red…
but sometimes the system gives some unexpected errors that I can’t notify by setting the led to red…
sincerly the real problem is the Memory Fault Error, so my question (after this laborious explanation) is: there is a way to prevent the memory fault error? because when it happen, the program is immediately terminated, giving me no way to do something (just turn on the led to red)

thanks, I hope this is a bit clear (sorry for this distressing english)

“a way to prevent memory fault”? Find out why it fault, and fix it. :slight_smile:

A “memory fault” is a “signal” dropped on your program, you can, however, “catch” this signal in your program. This way, you can run some code while you got hit. Check lib functions for “signal()”, and SIGSEGV.

mmm so I san just try/cathch it…well, this is the thing I wanna hear…thanks

It’s not a C++ exception: it is a signal (SIGSEGV) that gets “dropped” on your process when one of the threads in that process performs an invalid memory access (i.e. reading/writing an address that you is not mapped into your process’ memory space). Like xtang said: look at the signal() funtion in the help docs.