Force elapsed time display to zero if process seems started in the future

This commit is contained in:
Benny Baumann 2022-04-03 12:57:23 +02:00 committed by BenBE
parent ee1bf2f917
commit b83ce85d89
1 changed files with 9 additions and 1 deletions

View File

@ -871,7 +871,15 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
Process_printLeftAlignedField(str, attr, cwd, 25); Process_printLeftAlignedField(str, attr, cwd, 25);
return; return;
} }
case ELAPSED: Process_printTime(str, /* convert to hundreds of a second */ this->processList->realtimeMs / 10 - 100 * this->starttime_ctime, coloring); return; case ELAPSED: {
const uint64_t rt = this->processList->realtimeMs;
const uint64_t st = this->starttime_ctime * 1000;
const uint64_t dt =
rt < st ? 0 :
rt - st;
Process_printTime(str, /* convert to hundreds of a second */ dt / 10, coloring);
return;
}
case MAJFLT: Process_printCount(str, this->majflt, coloring); return; case MAJFLT: Process_printCount(str, this->majflt, coloring); return;
case MINFLT: Process_printCount(str, this->minflt, coloring); return; case MINFLT: Process_printCount(str, this->minflt, coloring); return;
case M_RESIDENT: Process_printKBytes(str, this->m_resident, coloring); return; case M_RESIDENT: Process_printKBytes(str, this->m_resident, coloring); return;