I have a pretty large application that dynamically loads shared objects and executes code in the shared object. As a precaution, I put a try/catch around almost everything in main. I created a catch for 3 things: myException (an in house exception), std::exception, and ... (catch all exceptions).
As part of the shared objects execution, many pthreads are created. When a thread throws an exception, it is not caught by main. Is this the standard behavior? How can I catch all exceptions, no matter what thread they are thrown from?
No
Yes, this is standard behaviour.
To catch an exception originating in thread
X, you have to have thetry–catchclause in threadX(for example, around everything in the thread function, similarly to what you already do inmain).For a related question, see How can I propagate exceptions between threads?