diff --git a/Process.c b/Process.c index 77e78f047..cb779749f 100644 --- a/Process.c +++ b/Process.c @@ -211,7 +211,12 @@ void Process_printTime(RichString* str, unsigned long long totalHundredths, bool int years = days / 365; int daysLeft = days - 365 * years; - if (daysLeft >= 100) { + if (years >= 10000000) { + RichString_appendnAscii(str, yearColor, "eternity ", 9); + } else if (years >= 1000) { + len = xSnprintf(buffer, sizeof(buffer), "%7dy ", years); + RichString_appendnAscii(str, yearColor, buffer, len); + } else if (daysLeft >= 100) { len = xSnprintf(buffer, sizeof(buffer), "%3dy", years); RichString_appendnAscii(str, yearColor, buffer, len); len = xSnprintf(buffer, sizeof(buffer), "%3dd ", daysLeft); @@ -871,7 +876,15 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field Process_printLeftAlignedField(str, attr, cwd, 25); 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 MINFLT: Process_printCount(str, this->minflt, coloring); return; case M_RESIDENT: Process_printKBytes(str, this->m_resident, coloring); return; diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index 54697116a..f58f33873 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -509,6 +509,9 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { proc->pgrp = kproc->ki_pgid; proc->st_uid = kproc->ki_uid; proc->starttime_ctime = kproc->ki_start.tv_sec; + if (proc->starttime_ctime < 0) { + proc->starttime_ctime = super->realtimeMs / 1000; + } Process_fillStarttimeBuffer(proc); proc->user = UsersTable_getRef(super->usersTable, proc->st_uid); ProcessList_add(super, proc);