![]() |
Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
I'm trying to write a signal handler that will convert the signal into a C++ style exception, but I'm having a major problem, it doesn't seem to work. Looking at the stack it seems that the fatal error is occuring in libstc++: #0 0x006e3e31 in kill () from /lib/libc.so.6 #1 0x006e3b31 in raise () from /lib/libc.so.6 #2 0x006e4ebf in abort () from /lib/libc.so.6 #3 0x00b80467 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5 #4 0x00b804a4 in std::terminate() () from /usr/lib/libstdc++.so.5 #5 0x00b80616 in __cxa_throw () from /usr/lib/libstdc++.so.5 #6 0x080488f9 in sigpipeHandler(int) (x=13) at test.cpp:9 #7 <signal handler called> #8 0x006e3e31 in kill () from /lib/libc.so.6 #9 0x006e3b31 in raise () from /lib/libc.so.6 #10 0x08048926 in main (argc=1, argv=0xbff67b34) at test.cpp:21 So here is my questions; Is it possible to do this in a safe consistant maner? And what am I doing wrong? Any help would be greatly appreciated. -fjr here is the code: #include <stdio.h> #include <iostream> #include <csignal> void sigpipeHandler(int x) { signal(SIGPIPE, sigpipeHandler); //reset the signal handler std::cerr << "throw: " << strsignal(x) << std::endl; throw strsignal(x); //throw the exeption } int main(int argc, char *argv[]) { int x; signal(SIGPIPE, sigpipeHandler); try { raise(SIGPIPE); } catch(const char *except) { std::cout << "catch: " << except << std::endl; } catch(...) { std::cout << "Exception" << std::endl; } std::cout << "done" << std::endl;; return 0; } -- Frank J. Ramsay fjramsay1234 at hotmail.com _________________________________________________________________ Find high-speed )B?net deals ? comparison-shop your local providers here. https://broadband.msn.com
![]() |
|
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |