diff --git a/src/btop.cpp b/src/btop.cpp index 3e5fa5e..86bba5f 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -541,9 +541,14 @@ namespace Runner { void run(const string& box, const bool no_update, const bool force_redraw) { atomic_wait_for(active, true, 5000); if (active) { - Global::exit_error_msg = "Stall in Runner thread, quitting!"; + Logger::error("Stall in Runner thread, restarting!"); active = false; - exit(1); + // exit(1); + pthread_cancel(Runner::runner_id); + if (pthread_create(&Runner::runner_id, NULL, &Runner::_runner, NULL) != 0) { + Global::exit_error_msg = "Failed to re-create _runner thread!"; + exit(1); + } } if (stopping or Global::resized) return; diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 9ba9bcc..6d3abaa 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -1354,7 +1354,7 @@ namespace Proc { uid_user.clear(); pread.open(Shared::passwd_path); if (pread.good()) { - while (not pread.eof()) { + while (pread.good()) { getline(pread, r_user, ':'); pread.ignore(SSmax, ':'); getline(pread, r_uid, ':'); @@ -1422,7 +1422,7 @@ namespace Proc { if (not pread.good()) continue; string uid; string line; - while (not pread.eof()) { + while (pread.good()) { getline(pread, line, ':'); if (line == "Uid") { pread.ignore(); @@ -1465,9 +1465,9 @@ namespace Proc { uint64_t cpu_t = 0; try { for (;;) { - while (++x < next_x + offset) pread.ignore(SSmax, ' '); - getline(pread, short_str, ' '); + while (pread.good() and ++x < next_x + offset) pread.ignore(SSmax, ' '); if (not pread.good()) break; + else getline(pread, short_str, ' '); switch (x-offset) { case 3: //? Process state