[omniORB] signals, threads, and C++ exceptions

Alexy Khrabrov alexy.khrabrov@setup.org
Mon Jul 22 21:41:01 2002


I have a MICO server which needs to be cleanly shut down
when SIGINT arrives (database connections closed, destructors
called, etc.).  Since MICO uses threads, I wonder how to do it
properly -- a simple signal handler in main() does the job, 
but gets called many times for some reason (by each thread?),
and I need Control-C twice to kill it, so something's fishy.  

The pthread book recommends to dedicate a thread to signal
handling, and mask out the signals on all other threads.
However, how can we do it with MICO's internal threads?

Ideally, I'd convert a signal to a C++ exception, but I could
not find any way to do it in g++...  Anybody knows a smart way
to convert signals to C++ exceptions?

Cheers,
Alexy