Added: Try to restart secondary thread in case of stall and addiotional error checks for ifstream in Proc::collect()

This commit is contained in:
aristocratos 2021-10-15 08:32:37 +02:00
parent 832699ffe6
commit e20258ea9f
2 changed files with 11 additions and 6 deletions

View file

@ -541,9 +541,14 @@ namespace Runner {
void run(const string& box, const bool no_update, const bool force_redraw) { void run(const string& box, const bool no_update, const bool force_redraw) {
atomic_wait_for(active, true, 5000); atomic_wait_for(active, true, 5000);
if (active) { if (active) {
Global::exit_error_msg = "Stall in Runner thread, quitting!"; Logger::error("Stall in Runner thread, restarting!");
active = false; 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; if (stopping or Global::resized) return;

View file

@ -1354,7 +1354,7 @@ namespace Proc {
uid_user.clear(); uid_user.clear();
pread.open(Shared::passwd_path); pread.open(Shared::passwd_path);
if (pread.good()) { if (pread.good()) {
while (not pread.eof()) { while (pread.good()) {
getline(pread, r_user, ':'); getline(pread, r_user, ':');
pread.ignore(SSmax, ':'); pread.ignore(SSmax, ':');
getline(pread, r_uid, ':'); getline(pread, r_uid, ':');
@ -1422,7 +1422,7 @@ namespace Proc {
if (not pread.good()) continue; if (not pread.good()) continue;
string uid; string uid;
string line; string line;
while (not pread.eof()) { while (pread.good()) {
getline(pread, line, ':'); getline(pread, line, ':');
if (line == "Uid") { if (line == "Uid") {
pread.ignore(); pread.ignore();
@ -1465,9 +1465,9 @@ namespace Proc {
uint64_t cpu_t = 0; uint64_t cpu_t = 0;
try { try {
for (;;) { for (;;) {
while (++x < next_x + offset) pread.ignore(SSmax, ' '); while (pread.good() and ++x < next_x + offset) pread.ignore(SSmax, ' ');
getline(pread, short_str, ' ');
if (not pread.good()) break; if (not pread.good()) break;
else getline(pread, short_str, ' ');
switch (x-offset) { switch (x-offset) {
case 3: //? Process state case 3: //? Process state