Mrntt: Shut down mind threads before printing usage & exiting

This commit is contained in:
2025-08-03 09:57:29 -04:00
parent 285b63b618
commit fef73692f7
+20 -5
View File
@@ -27,7 +27,7 @@ void ComponentThread::marionetteMain(ComponentThread& self)
std::cout << __func__ << ": Waiting for command line JOLT" << std::endl; std::cout << __func__ << ": Waiting for command line JOLT" << std::endl;
self.getIoService().run(); self.getIoService().run();
self.initializeTls(); self.initializeTls();
mrntt::exitCode = 0; mrntt::exitCode = EXIT_SUCCESS;
try { try {
OptionParser &options = OptionParser::getOptions(); OptionParser &options = OptionParser::getOptions();
@@ -48,14 +48,29 @@ void ComponentThread::marionetteMain(ComponentThread& self)
std::cerr << __func__ << ": Exception occurred: " << e.what() std::cerr << __func__ << ": Exception occurred: " << e.what()
<< '\n' << options.getUsage() << '\n'; << '\n' << options.getUsage() << '\n';
mrntt::exitCode = EXIT_FAILURE; options.printUsage = true;
return; mrntt::exitCode = EXIT_FAILURE;
} }
if (options.printUsage) if (options.printUsage)
{ {
std::cout << __func__ << ": " << options.getUsage() << std::endl; self.getIoService().post([&options]()
mrntt::exitCode = EXIT_SUCCESS; {
ComponentThread::joltAllMindThreadsReq(
[&options]()
{
ComponentThread::exitAllMindThreadsReq(
[&options]()
{
std::cout << __func__ << ": " << options.getUsage()
<< '\n';
mrntt::mrntt->getIoService().stop();
}
);
});
});
self.getIoService().reset();
self.getIoService().run();
return; return;
} }