diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index ba0779fb..68baf96d 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -225,13 +225,6 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) case STIME: Process_printTime(str, lp->stime); return; case CUTIME: Process_printTime(str, lp->cutime); return; case CSTIME: Process_printTime(str, lp->cstime); return; - case STARTTIME: { - struct tm date; - time_t starttimewall = btime + (lp->starttime / sysconf(_SC_CLK_TCK)); - (void) localtime_r(&starttimewall, &date); - strftime(buffer, n, ((starttimewall > time(NULL) - 86400) ? "%R " : "%b%d "), &date); - break; - } #ifdef HAVE_TASKSTATS case RCHAR: Process_colorNumber(str, lp->io_rchar, coloring); return; case WCHAR: Process_colorNumber(str, lp->io_wchar, coloring); return; @@ -334,12 +327,6 @@ long LinuxProcess_compare(const void* v1, const void* v2) { case CUTIME: diff = p2->cutime - p1->cutime; goto test_diff; case STIME: diff = p2->stime - p1->stime; goto test_diff; case CSTIME: diff = p2->cstime - p1->cstime; goto test_diff; - case STARTTIME: { - if (p1->starttime == p2->starttime) - return (p1->super.pid - p2->super.pid); - else - return (p1->starttime - p2->starttime); - } #ifdef HAVE_TASKSTATS case RCHAR: diff = p2->io_rchar - p1->io_rchar; goto test_diff; case WCHAR: diff = p2->io_wchar - p1->io_wchar; goto test_diff; diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 8113193f..ac80317d 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -107,7 +107,6 @@ typedef struct LinuxProcess_ { long m_drs; long m_lrs; long m_dt; - unsigned long long starttime; #ifdef HAVE_TASKSTATS unsigned long long io_rchar; unsigned long long io_wchar; diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 7a31debf..ceb7f7bf 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -260,9 +260,8 @@ void ProcessList_delete(ProcessList* pl) { free(this); } -static double jiffy = NAN; - static inline unsigned long long LinuxProcess_adjustTime(unsigned long long t) { + static double jiffy = NAN; if(isnan(jiffy)) { errno = 0; long sc_jiffy = sysconf(_SC_CLK_TCK); @@ -345,7 +344,11 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname, process->nlwp = strtol(location, &location, 10); location += 1; location = strchr(location, ' ')+1; - lp->starttime = strtoll(location, &location, 10); + if (process->starttime_ctime == 0) { + process->starttime_ctime = btime + LinuxProcess_adjustTime(strtoll(location, &location, 10)) / 100; + } else { + location = strchr(location, ' ')+1; + } location += 1; for (int i=0; i<15; i++) location = strchr(location, ' ')+1; process->exit_signal = strtol(location, &location, 10); @@ -1032,6 +1035,10 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* goto errorReadingProcess; } + struct tm date; + (void) localtime_r(&proc->starttime_ctime, &date); + strftime(proc->starttime_show, 7, ((proc->starttime_ctime > tv.tv_sec - 86400) ? "%R " : "%b%d "), &date); + ProcessList_add(pl, proc); } else { if (settings->updateProcessNames && proc->state != 'Z') {