added ps etimes, miscellaneous top enhancements
ps program . etimes added for ELAPSED expressed in seconds . time_t used in place of former unsigned long top program . corrected scroll message bug when 'x' toggle on . fixed forest view potential missing libflags bug . improved 'k' default signal invocation logic . enhanced logic for %CPU maximums displayed . made signal handling more robust and efficient
This commit is contained in:
19
ps/output.c
19
ps/output.c
@ -76,7 +76,8 @@ static unsigned max_leftward = 0x12345678; /* space for LEFT stuff */
|
||||
|
||||
static int wide_signals; /* true if we have room */
|
||||
|
||||
static unsigned long seconds_since_1970;
|
||||
static time_t seconds_since_1970;
|
||||
static time_t time_of_boot;
|
||||
static unsigned long page_shift;
|
||||
|
||||
|
||||
@ -277,6 +278,13 @@ STIME stime hms or md time format
|
||||
***/
|
||||
|
||||
/* Source & destination are known. Return bytes or screen characters? */
|
||||
//
|
||||
// OldLinux FreeBSD HPUX
|
||||
// ' ' ' ' ' ' ' '
|
||||
// 'L' ' \_ ' '`-' ' '
|
||||
// '+' ' \_ ' '|-' ' '
|
||||
// '|' ' | ' '| ' ' '
|
||||
//
|
||||
static int forest_helper(char *restrict const outbuf){
|
||||
char *p = forest_prefix;
|
||||
char *q = outbuf;
|
||||
@ -430,6 +438,12 @@ static int pr_etime(char *restrict const outbuf, const proc_t *restrict const pp
|
||||
return (int)(cp-outbuf);
|
||||
}
|
||||
|
||||
/* elapsed wall clock time in seconds */
|
||||
static int pr_etimes(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
unsigned t = seconds_since_boot - (unsigned long)(pp->start_time / Hertz);
|
||||
return snprintf(outbuf, COLWID, "%u", t);
|
||||
}
|
||||
|
||||
/* "Processor utilisation for scheduling." --- we use %cpu w/o fraction */
|
||||
static int pr_c(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
unsigned long long total_time; /* jiffies used by this process */
|
||||
@ -950,7 +964,7 @@ static int pr_start(char *restrict const outbuf, const proc_t *restrict const pp
|
||||
str = ctime(&t);
|
||||
if(str[8]==' ') str[8]='0';
|
||||
if(str[11]==' ') str[11]='0';
|
||||
if((unsigned long)t+60*60*24 > seconds_since_1970)
|
||||
if((unsigned long)t+60*60*24 > (unsigned long)seconds_since_1970)
|
||||
return snprintf(outbuf, COLWID, "%8.8s", str+11);
|
||||
return snprintf(outbuf, COLWID, " %6.6s", str+4);
|
||||
}
|
||||
@ -1345,6 +1359,7 @@ static const format_struct format_array[] = {
|
||||
{"environ","ENVIRONMENT",pr_nop, sr_nop, 11, ENV, LNx, PO|UNLIMITED},
|
||||
{"esp", "ESP", pr_esp, sr_kstk_esp, 8, 0, LNX, TO|RIGHT},
|
||||
{"etime", "ELAPSED", pr_etime, sr_nop, 11, 0, U98, ET|RIGHT}, /* was 7 wide */
|
||||
{"etimes", "ELAPSED", pr_etimes, sr_nop, 7, 0, BSD, ET|RIGHT}, /* FreeBSD */
|
||||
{"euid", "EUID", pr_euid, sr_euid, 5, 0, LNX, ET|RIGHT},
|
||||
{"euser", "EUSER", pr_euser, sr_euser, 8, USR, LNX, ET|USER},
|
||||
{"f", "F", pr_flag, sr_flags, 1, 0, XXX, ET|RIGHT}, /*flags*/
|
||||
|
Reference in New Issue
Block a user