From 70b2d8794f3b78c2028dd6e8d00444b178e76893 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Wed, 21 Aug 2024 10:19:39 -0400 Subject: [PATCH] example: Add missing thread.join() call so example can exit cleanly Problem was pointed out by TheCharlatan in https://github.com/chaincodelabs/libmultiprocess/pull/107#issuecomment-2301338227 --- example/example.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/example/example.cpp b/example/example.cpp index 8760d8a9..036dcb53 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -49,8 +49,9 @@ int main(int argc, char** argv) auto calc = calc_init->makeCalculator(printer_init->makePrinter()); while (true) { std::string eqn; - std::cout << "Enter the equation: "; + std::cout << "Enter the equation, or \"exit\" to quit: "; std::getline(std::cin, eqn); + if (eqn == "exit") break; calc->solveEquation(eqn); } calc.reset(); @@ -58,5 +59,7 @@ int main(int argc, char** argv) mp::WaitProcess(calc_pid); printer_init.reset(); mp::WaitProcess(printer_pid); + loop_thread.join(); + std::cout << "Bye!" << std::endl; return 0; }