[lug] Re: g++ signals and exceptions question
zlynx at acm.org
Wed May 15 14:45:32 MDT 2002
On Wed, 2002-05-15 at 14:22, Matt Armstrong wrote:
> Jonathan Briggs <zlynx at acm.org> writes:
> > Functions such as siglongjmp can manipulate the original program
> > stack and go somewhere else. Does anyone know of a C++ (it can be
> > g++ / Linux specific) function or library that would allow raising
> > an exception from a signal handler?
> > If it doesn't exist, I might try writing it.
> I think it is basically impossible to implement the idea in C++.
> You'd need support from the compiler, and that support would basically
> implement the "check a global variable" trick at, say, every function
> call or entry into every basic block.
When I said I might try writing it myself, I was thinking that it should
be possible to write a function that would examine the stack and fix it
so that it would place the exception object properly and set things so
that after the signal handler returned, the exception handler would run.
The function could be called something like this:
sigthrow(signal_exception e("I'm a signal!"));
Parts of this function might need to be written in assembly. I'd look
at how the GNU C Library implemented siglongjmp.
To do it so it would work transparently from inside signal handlers, I'd
need to modify g++ and possibly libstdc++. This is possible, because
the Sun C++ compiler can do it, in certain versions.
jbriggs at esoft.com
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 232 bytes
Desc: This is a digitally signed message part
More information about the LUG