This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Converting SIGSEGV etc. signals to exceptions
- From: sudhakar govindavajhala <sudhakarg79spam at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 20 Aug 2011 08:51:44 -0400
- Subject: Converting SIGSEGV etc. signals to exceptions
Hi there,
I am writing C++ code in Linux (2.6.18) using pthreads. glibc 2.5. gcc 4.1.2
1) I understand that signals SIGFPE and SIGSEGV are sent to individual
threads while SIGINT is sent to the whole process.? How do I find out
what signal is thread specific and what signal is process wide.? How
does the OS/glibc determine which thread should be served the signal?
2) I would like to translate SIGSEGV or SIGFPE to an exception in the
program so that it can be caught at higher levels. Is there a default
option to convert a SIGSEGV to an exception?? For my tests, I provided
a signal handler for SIGSEGV/SIGFPE that throws an int exception and
it works. Is it legal to throw exceptions in signal handlers? Is there
any limitation on what kind of object can be thrown as an exception?
Could someone help me understand the rules in this space?
3) Could someone point me to? a sample to print the stack trace when
an exception occurred?
Thank you.
Sincerely
Sudhakar