int main(int argc,char *argv[]) { try { try { init(); thread threadCar(threadServerCar); thread threadWorker(threadServerWorker); threadCar.detach(); threadWorker.detach(); try { SignalHandler signalHandler; // Register signal handler to handle kill signal signalHandler.setupSignalHandlers(); // Infinite loop until signal ctrl-c (KILL) received while (!signalHandler.gotExitSignal()) { std::this_thread::sleep_for(1s); } } catch (SignalException& e) { std::cerr << "SignalException: " << e.what() << std::endl; } } catch(boost::exception_ptr & e) { BOOST_LOG_TRIVIAL(fatal) << "boost fatal" << boost::diagnostic_information(e); exit(-1); } } catch (...) { BOOST_LOG_TRIVIAL(fatal) << "unknown fatal in main thread"; exit(-1); } return 0; }