mirror of https://github.com/xzeldon/htop.git
STARTTIME column
This commit is contained in:
parent
22b0d7df64
commit
dc262f4df6
|
@ -27,6 +27,7 @@ in the source distribution for its full text.
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef HAVE_PLPA
|
#ifdef HAVE_PLPA
|
||||||
#include <plpa.h>
|
#include <plpa.h>
|
||||||
|
@ -98,9 +99,10 @@ typedef struct Process_ {
|
||||||
long int priority;
|
long int priority;
|
||||||
long int nice;
|
long int nice;
|
||||||
long int nlwp;
|
long int nlwp;
|
||||||
|
char starttime_show[8];
|
||||||
|
time_t starttime_ctime;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
long int itrealvalue;
|
long int itrealvalue;
|
||||||
unsigned long int starttime;
|
|
||||||
unsigned long int vsize;
|
unsigned long int vsize;
|
||||||
long int rss;
|
long int rss;
|
||||||
unsigned long int rlim;
|
unsigned long int rlim;
|
||||||
|
@ -186,7 +188,7 @@ const char *Process_fieldTitles[] = {
|
||||||
"", " PID ", "Command ", "S ", " PPID ", " PGRP ", " SESN ",
|
"", " PID ", "Command ", "S ", " PPID ", " PGRP ", " SESN ",
|
||||||
" TTY ", "TPGID ", "- ", "- ", "- ", "- ", "- ",
|
" TTY ", "TPGID ", "- ", "- ", "- ", "- ", "- ",
|
||||||
" UTIME+ ", " STIME+ ", "- ", "- ", "PRI ", " NI ", "- ",
|
" UTIME+ ", " STIME+ ", "- ", "- ", "PRI ", " NI ", "- ",
|
||||||
"- ", "- ", "- ", "- ", "- ", "- ", "- ",
|
"START ", "- ", "- ", "- ", "- ", "- ", "- ",
|
||||||
"- ", "- ", "- ", "- ", "- ", "- ", "- ",
|
"- ", "- ", "- ", "- ", "- ", "- ", "- ",
|
||||||
"- ", "- ", "- ", "CPU ", " VIRT ", " RES ", " SHR ",
|
"- ", "- ", "- ", "CPU ", " VIRT ", " RES ", " SHR ",
|
||||||
" CODE ", " DATA ", " LIB ", " DIRTY ", " UID ", "CPU% ", "MEM% ",
|
" CODE ", " DATA ", " LIB ", " DIRTY ", " UID ", "CPU% ", "MEM% ",
|
||||||
|
@ -403,6 +405,7 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case STARTTIME: snprintf(buffer, n, "%s", this->starttime_show); break;
|
||||||
#ifdef HAVE_OPENVZ
|
#ifdef HAVE_OPENVZ
|
||||||
case CTID: snprintf(buffer, n, "%5u ", this->ctid); break;
|
case CTID: snprintf(buffer, n, "%5u ", this->ctid); break;
|
||||||
case VPID: snprintf(buffer, n, "%5u ", this->vpid); break;
|
case VPID: snprintf(buffer, n, "%5u ", this->vpid); break;
|
||||||
|
@ -578,6 +581,8 @@ int Process_compare(const void* v1, const void* v2) {
|
||||||
return strcmp(p1->comm, p2->comm);
|
return strcmp(p1->comm, p2->comm);
|
||||||
case NLWP:
|
case NLWP:
|
||||||
return (p1->nlwp - p2->nlwp);
|
return (p1->nlwp - p2->nlwp);
|
||||||
|
case STARTTIME:
|
||||||
|
return (p1->starttime_ctime - p2->starttime_ctime);
|
||||||
#ifdef HAVE_OPENVZ
|
#ifdef HAVE_OPENVZ
|
||||||
case CTID:
|
case CTID:
|
||||||
return (p1->ctid - p2->ctid);
|
return (p1->ctid - p2->ctid);
|
||||||
|
|
|
@ -30,6 +30,7 @@ in the source distribution for its full text.
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef HAVE_PLPA
|
#ifdef HAVE_PLPA
|
||||||
#include <plpa.h>
|
#include <plpa.h>
|
||||||
|
@ -100,9 +101,10 @@ typedef struct Process_ {
|
||||||
long int priority;
|
long int priority;
|
||||||
long int nice;
|
long int nice;
|
||||||
long int nlwp;
|
long int nlwp;
|
||||||
|
char starttime_show[8];
|
||||||
|
time_t starttime_ctime;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
long int itrealvalue;
|
long int itrealvalue;
|
||||||
unsigned long int starttime;
|
|
||||||
unsigned long int vsize;
|
unsigned long int vsize;
|
||||||
long int rss;
|
long int rss;
|
||||||
unsigned long int rlim;
|
unsigned long int rlim;
|
||||||
|
|
|
@ -431,7 +431,7 @@ static int ProcessList_readStatFile(Process *proc, FILE *f, char *command) {
|
||||||
&proc->minflt, &proc->cminflt, &proc->majflt, &proc->cmajflt,
|
&proc->minflt, &proc->cminflt, &proc->majflt, &proc->cmajflt,
|
||||||
&proc->utime, &proc->stime, &proc->cutime, &proc->cstime,
|
&proc->utime, &proc->stime, &proc->cutime, &proc->cstime,
|
||||||
&proc->priority, &proc->nice, &proc->nlwp, &proc->itrealvalue,
|
&proc->priority, &proc->nice, &proc->nlwp, &proc->itrealvalue,
|
||||||
&proc->starttime, &proc->vsize, &proc->rss, &proc->rlim,
|
&zero, &proc->vsize, &proc->rss, &proc->rlim,
|
||||||
&proc->startcode, &proc->endcode, &proc->startstack, &proc->kstkesp,
|
&proc->startcode, &proc->endcode, &proc->startstack, &proc->kstkesp,
|
||||||
&proc->kstkeip, &proc->signal, &proc->blocked, &proc->sigignore,
|
&proc->kstkeip, &proc->signal, &proc->blocked, &proc->sigignore,
|
||||||
&proc->sigcatch, &proc->wchan, &proc->nswap, &proc->cnswap,
|
&proc->sigcatch, &proc->wchan, &proc->nswap, &proc->cnswap,
|
||||||
|
@ -474,6 +474,13 @@ static bool ProcessList_readStatusFile(Process* proc, const char* dirname, char*
|
||||||
if (statok == -1)
|
if (statok == -1)
|
||||||
return false;
|
return false;
|
||||||
proc->st_uid = sstat.st_uid;
|
proc->st_uid = sstat.st_uid;
|
||||||
|
|
||||||
|
struct tm date;
|
||||||
|
time_t ctime = sstat.st_ctime;
|
||||||
|
proc->starttime_ctime = ctime;
|
||||||
|
(void) localtime_r((time_t*) &ctime, &date);
|
||||||
|
strftime(proc->starttime_show, 7, ((ctime > time(NULL) - 86400) ? "%R " : "%b%d "), &date);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue