From 95cc4c37bb775c95a3795798ee28458ef4fddd30 Mon Sep 17 00:00:00 2001 From: albert <> Date: Thu, 6 Jan 2005 00:13:12 +0000 Subject: [PATCH] variable-width %CPU,PPID,PID --- NEWS | 8 +++++--- ps/display.c | 1 + top.c | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index a6258354..b7b63081 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,14 @@ procps-3.2.4 --> procps-3.2.5 -display problem on 64-bit systems fixed +display problem on 64-bit systems fixed #287947 +top: variable-width PID and PPID +top: variable-width %CPU rh110555 sysctl: better error messages ps: security labels can contain any printable ASCII top: help and version message on stdout, with exit(0) #283541 -ps: SIGTSTP from ^Z shouldn't print bug email address +ps: SIGTSTP and SIGTTOU shouldn't print bug email address #246123 slabtop: compile with glibc 2.2.17 (and older, likely) -slabtop: fix overflow on huge NUMA boxes +slabtop: fix overflow on huge NUMA boxes #264640 procps-3.2.3 --> procps-3.2.4 diff --git a/ps/display.c b/ps/display.c index f9c8e23c..4574b9c8 100644 --- a/ps/display.c +++ b/ps/display.c @@ -564,6 +564,7 @@ int main(int argc, char *argv[]){ case 0: case SIGINT: /* ^C */ case SIGTSTP: /* ^Z */ + case SIGTTOU: /* see stty(1) man page */ case SIGQUIT: /* ^\ */ case SIGPROF: /* profiling */ case SIGKILL: /* can not catch */ diff --git a/top.c b/top.c index dcb6d08b..e23fe2c8 100644 --- a/top.c +++ b/top.c @@ -77,6 +77,7 @@ static unsigned page_to_kb_shift; /* SMP Irix/Solaris mode */ static int Cpu_tot; +static double pcpu_max_value; // usually 99.9, for %CPU display /* assume no IO-wait stats, overridden if linux 2.5.41 */ static const char *States_fmts = STATES_line2x4; @@ -1551,6 +1552,39 @@ static void before (char *me) i >>= 1; page_to_kb_shift++; } + + Fieldstab[P_CPU].head = " %CPU"; + Fieldstab[P_CPU].fmts = " %#4.1f"; + pcpu_max_value = 99.9; + Fieldstab[P_CPN].head = " P"; + Fieldstab[P_CPN].fmts = " %1u"; + if(smp_num_cpus>9){ + Fieldstab[P_CPN].head = " P"; + Fieldstab[P_CPN].fmts = " %2u"; + if(Rc.mode_irixps){ + // this will do for up to 999; hopefully a 1024-node box + // will have at least 2.4% idle time + pcpu_max_value = 9999.0; + Fieldstab[P_CPU].fmts = " %4.0f"; + } + } + if(smp_num_cpus>99){ + Fieldstab[P_CPN].head = " P"; + Fieldstab[P_CPN].fmts = " %3u"; + } + if(smp_num_cpus>999){ + Fieldstab[P_CPN].head = " P"; + Fieldstab[P_CPN].fmts = " %4u"; + } + + unsigned pid_digits = get_pid_digits(); + if(pid_digits<4) pid_digits=4; + static char pid_fmt[6]; + snprintf(pid_fmt, sizeof pid_fmt, " %%%uu", pid_digits); + Fieldstab[P_PID].fmts = pid_fmt; + Fieldstab[P_PID].head = " PID" + 10 - pid_digits; + Fieldstab[P_PPD].fmts = pid_fmt; + Fieldstab[P_PPD].head = " PPID" + 10 - pid_digits; } @@ -2941,7 +2975,7 @@ static void task_show (const WIN_t *q, const proc_t *p) break; case P_CPU: { float u = (float)p->pcpu * Frame_tscale; - if (99.9 < u) u = 99.9; + if (u > pcpu_max_value) u = pcpu_max_value; MKCOL(u); } break;