[lug] g++ signals and exceptions question

Jonathan Briggs zlynx at acm.org
Wed May 15 10:59:47 MDT 2002

I should probably ask this question on one of the C++ newsgroups, but I
haven't had decent newsgroup access for a few months now.  On to the

I was thinking that it would be pretty neat if a C++ program could catch
a signal and raise an exception.  I tried throwing an exception from a
signal handler, but that only resulted in a messy crash.  I'm sure this
is because signal handlers use a completely different program stack
while running.

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.

Do any of you who are experienced C++ programmers see anything wrong
with this idea?  One problem I thought of is that it might violate
exception restrictions (functions that declare they will never throw, or
will only throw exceptions of type int, for example.)
Jonathan Briggs
jbriggs at esoft.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 232 bytes
Desc: This is a digitally signed message part
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20020515/42da1ef6/attachment.pgp>

More information about the LUG mailing list