From 44e9a5bd113868769615d342a77fa47651dd9459 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 26 Jan 2018 10:39:23 +0100 Subject: [PATCH] fix stdin bug returning eof in input loop --- srsue/src/main.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 0f668b927..eee5e2282 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -403,14 +403,19 @@ void *input_loop(void *m) { char key; while (running) { cin >> key; - if ('t' == key) { - do_metrics = !do_metrics; - if (do_metrics) { - cout << "Enter t to stop trace." << endl; - } else { - cout << "Enter t to restart trace." << endl; + if (cin.eof() || cin.bad()) { + cout << "Closing stdin thread\n" << endl; + break; + } else { + if ('t' == key) { + do_metrics = !do_metrics; + if (do_metrics) { + cout << "Enter t to stop trace." << endl; + } else { + cout << "Enter t to restart trace." << endl; + } + metrics_screen.toggle_print(do_metrics); } - metrics_screen.toggle_print(do_metrics); } } return NULL;