I am porting a Windows program on Linux. My program uses the Windows structured exception handling (SEH). Linux does not support structured exception handling, however it provides signal handling. We can override signal to develop SEH like paradigm.
Once you are able to filter the exception Windows provides three alternatives execution control flows:
1) EXCEPTION_EXECUTE_HANDLER : Execute handler 2) EXCEPTION_CONTINUE_SEARCH : Forward the exception to next block (if not exist then to OS) 3) EXCEPTION_CONTINUE_EXECUTION : Continue exception from the instruction where interrupt has occured.
How can I achieve this control flows in Linux. In Linux once you handle the signal, program starts execution from where it has been interrupted. How to develope continue_search and execute_handler paradigms?
Thanks in advance
There is no easy way to do what you want here in C++. Your tools are the standard C++ exception mechanism, and sigaction
. A sigaction
handler can return control to where it left off. It can throw, though there has been controversy about the safety of this. Some would say that it has to set an atomic variable and return. (The problem being that the compiler sees no possibility of a throw and so doesn't prepare for it.)
If you are working in C, you have additional complex options involving sigsetjmp
, which is more or less goto on steroids, risks and all.
Since you haven't specified a language, or what exceptional condition you are trying to deal with, it's not practical to offer a more specific recipe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With