Unix Signals as OS Exceptions in C++
Richard Henderson
rth@redhat.com
Sun Sep 12 21:25:00 GMT 2004
On Sun, Sep 12, 2004 at 10:15:20AM -0400, Ian Lance Taylor wrote:
> It already works fine; just call throw from your signal handler.
This WILL NOT work in general with asynchronous signals, and will
NEVER work in general.
It works for cases like your sleep case here because you're nicely
synchronized on a function call. Of course, glibc has been adding
nothrow all over the place, so pretty much anything that isn't a
POSIX cancelation point won't work here.
If you *do* want to operate with synchronous signals, SEGV and FPE,
you'll need to compile with -fnon-call-exceptions. See libjava for
the "interesting" things you have to do with the signal frame in
order to get the unwind to reliably find the exception data (rather
than merely unwind the stack).
And this only works for ports that have MD_FALLBACK_FRAME_STATE_FOR,
or somehow have unwind info in the signal trampoline. Which is
pretty much just Linux and Darwin.
r~
More information about the Gcc
mailing list