diff --git a/smocore/marionette/marionette.cpp b/smocore/marionette/marionette.cpp index 4cc1d69..5117d06 100644 --- a/smocore/marionette/marionette.cpp +++ b/smocore/marionette/marionette.cpp @@ -27,7 +27,7 @@ void ComponentThread::marionetteMain(ComponentThread& self) std::cout << __func__ << ": Waiting for command line JOLT" << std::endl; self.getIoService().run(); self.initializeTls(); - mrntt::exitCode = 0; + mrntt::exitCode = EXIT_SUCCESS; try { OptionParser &options = OptionParser::getOptions(); @@ -48,14 +48,29 @@ void ComponentThread::marionetteMain(ComponentThread& self) std::cerr << __func__ << ": Exception occurred: " << e.what() << '\n' << options.getUsage() << '\n'; - mrntt::exitCode = EXIT_FAILURE; - return; + options.printUsage = true; + mrntt::exitCode = EXIT_FAILURE; } if (options.printUsage) { - std::cout << __func__ << ": " << options.getUsage() << std::endl; - mrntt::exitCode = EXIT_SUCCESS; + self.getIoService().post([&options]() + { + ComponentThread::joltAllMindThreadsReq( + [&options]() + { + ComponentThread::exitAllMindThreadsReq( + [&options]() + { + std::cout << __func__ << ": " << options.getUsage() + << '\n'; + mrntt::mrntt->getIoService().stop(); + } + ); + }); + }); + self.getIoService().reset(); + self.getIoService().run(); return; }