This program terminates before the exception handler is caught
void main(){
try{
work1();
std::thread joinableThread(
[](){
work2();
}
);
work3();
throw std::runtime_error("catch me if you can");
joinableThread.join();
} catch(const std::runtime_error& ex){
std::cout << "You did it!" << std::endl;
}
}
I would like to process the exception handler but the program terminates during stack unwinding. What can I do to ensure that the thread is joined during stack unwidning?