summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-12 12:51:18 +0200
committercgzones <cgzones@googlemail.com>2020-10-16 19:23:40 +0200
commit783be7711db0081a77fbcf84fbb63ab2a31ccc05 (patch)
treed24e2dc8329a3393b764c67810d2778c3feb14b1 /linux
parentd744dac7ee6a651670387b6cc83878ef82202839 (diff)
Do not use extra starttime process field on Linux
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcess.c13
-rw-r--r--linux/LinuxProcess.h1
-rw-r--r--linux/LinuxProcessList.c13
3 files changed, 10 insertions, 17 deletions
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') {

© 2014-2024 Faster IT GmbH | imprint | privacy policy