From 25273095adc6e6c1e592415bf72a3c8f44188b42 Mon Sep 17 00:00:00 2001 From: albert <> Date: Fri, 8 Nov 2002 07:42:54 +0000 Subject: [PATCH] never-ending vmstat code cleanup --- NEWS | 1 + vmstat.c | 132 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 70 insertions(+), 63 deletions(-) diff --git a/NEWS b/NEWS index dba3d7ad..a8c5a6dc 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ procps-3.0.5 --> procps-3.0.6 can build w/o shared library (set SHARED=0) when IO-wait hidden, count as idle, not as sys pmap command added (like Sun has) +do not crash GNU make 3.79 procps-3.0.4 --> procps-3.0.5 diff --git a/vmstat.c b/vmstat.c index d7f94f2f..b5bc833a 100644 --- a/vmstat.c +++ b/vmstat.c @@ -43,6 +43,11 @@ static char buff[BUFFSIZE]; /* used in the procedures */ typedef unsigned long long jiff; static int a_option; /* "-a" means "show active/inactive" */ +static unsigned sleep_time = 1; +static unsigned long num_updates; + +static unsigned int height=22; // window height, reset later if needed +static unsigned int moreheaders=TRUE; /****************************************************************/ @@ -181,15 +186,9 @@ static void getrunners(unsigned int *running, unsigned int *blocked, - -int main(int argc, char *argv[]) { - +////////////////////////////////////////////////////////////////////////////////////// +void old_format(void) { const char format[]="%2u %2u %2u %6u %6u %6u %6u %4u %4u %5u %5u %4u %5u %2u %2u %2u\n"; - unsigned int height=22; /* window height, reset later if needed. */ -#if 0 - unsigned long int args[2]={0,0}; -#endif - unsigned int moreheaders=TRUE; unsigned int tog=0; /* toggle switch for cleaner code */ unsigned int i; unsigned int hz = Hertz; @@ -198,55 +197,10 @@ int main(int argc, char *argv[]) { jiff duse,dsys,didl,Div,divo2; unsigned int pgpgin[2], pgpgout[2], pswpin[2], pswpout[2]; unsigned int inter[2],ticks[2],ctxt[2]; - unsigned int per=0, pero2; - unsigned long num=0; + unsigned int sleep_half; unsigned int kb_per_page = sysconf(_SC_PAGESIZE) / 1024; - setlinebuf(stdout); - argc=0; /* redefined as number of integer arguments */ - per=1; - num=0; - for (argv++;*argv;argv++) { - if ('-' ==(**argv)) { - switch (*(++(*argv))) { - case 'V': - display_version(); - exit(0); - case 'a': - /* active/inactive mode */ - a_option=1; - break; - case 'n': - /* print only one header */ - moreheaders=FALSE; - break; - default: - /* no other aguments defined yet. */ - usage(); - } - } else { - argc++; - switch (argc) { - case 1: - if ((per = atoi(*argv)) == 0) - usage(); - num = ULONG_MAX; - break; - case 2: - num = atol(*argv); - break; - default: - usage(); - } /* switch */ - } - } - - if (moreheaders) { - int tmp=winhi()-3; - height=((tmp>0)?tmp:22); - } - - pero2=(per/2); + sleep_half=(sleep_time/2); showheader(); getrunners(&running,&blocked,&swapped); @@ -275,8 +229,8 @@ int main(int argc, char *argv[]) { (unsigned)( (100*didl + divo2) / Div ) ); - for(i=1;i0)?tmp:22); + } + + setlinebuf(stdout); + + old_format(); + return 0; +} + +