Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vmstat Make -c and -w work properly when printing no...



details:   https://anonhg.NetBSD.org/src/rev/7691c6df7df6
branches:  trunk
changeset: 508074:7691c6df7df6
user:      jhawk <jhawk%NetBSD.org@localhost>
date:      Thu Apr 05 20:04:03 2001 +0000

description:
Make -c and -w work properly when printing non-default statistics.

diffstat:

 usr.bin/vmstat/vmstat.c |  55 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 20 deletions(-)

diffs (76 lines):

diff -r c15b4ff67f43 -r 7691c6df7df6 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Thu Apr 05 19:55:01 2001 +0000
+++ b/usr.bin/vmstat/vmstat.c   Thu Apr 05 20:04:03 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.77 2001/03/09 02:42:23 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.78 2001/04/05 20:04:03 jhawk Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.77 2001/03/09 02:42:23 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.78 2001/04/05 20:04:03 jhawk Exp $");
 #endif
 #endif /* not lint */
 
@@ -330,24 +330,39 @@
        } else if (reps)
                interval = 1;
 
-       if (todo & (HISTLIST|HISTDUMP)) {
-               if ((todo & (HISTLIST|HISTDUMP)) == (HISTLIST|HISTDUMP))
-                       errx(1, "you may list or dump, but not both!");
-               hist_traverse(todo, histname);
-       }
-       if (todo & FORKSTAT)
-               doforkst();
-       if (todo & MEMSTAT) {
-               domem();
-               dopool();
-       }
-       if (todo & SUMSTAT)
-               dosum();
-       if (todo & INTRSTAT)
-               dointr(verbose);
-       if (todo & EVCNTSTAT)
-               doevcnt(verbose);
-       if (todo & VMSTAT)
+
+       /*
+        * Statistics dumping is incompatible with the default
+        * VMSTAT/dovmstat() output. So perform the interval/reps handling
+        * for it here.
+        */
+       if ((todo & VMSTAT) == 0)
+           for (;;) {
+               if (todo & (HISTLIST|HISTDUMP)) {
+                       if ((todo & (HISTLIST|HISTDUMP)) ==
+                           (HISTLIST|HISTDUMP))
+                               errx(1, "you may list or dump, but not both!");
+                       hist_traverse(todo, histname);
+               }
+               if (todo & FORKSTAT)
+                       doforkst();
+               if (todo & MEMSTAT) {
+                       domem();
+                       dopool();
+               }
+               if (todo & SUMSTAT)
+                       dosum();
+               if (todo & INTRSTAT)
+                       dointr(verbose);
+               if (todo & EVCNTSTAT)
+                       doevcnt(verbose);
+               
+               if (reps >= 0 && --reps <=0) 
+                   break;
+               sleep(interval);
+               puts("");
+           }
+       else
                dovmstat(interval, reps);
        exit(0);
 }



Home | Main Index | Thread Index | Old Index