summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-07-14 22:50:32 +0000
committerMiles Bader <miles@gnu.org>1997-07-14 22:50:32 +0000
commitd8b6843aca3286d966d414dcaca7f3673f415970 (patch)
tree395fb06e43de2d21d313935f36d13eb25fd14945
parent827155d3773460884173e12874e7d883d78b5b0c (diff)
(main):
Don't print fields we cannot get.
-rw-r--r--utils/vmstat.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/utils/vmstat.c b/utils/vmstat.c
index 418f2878..bada18f9 100644
--- a/utils/vmstat.c
+++ b/utils/vmstat.c
@@ -567,17 +567,24 @@ main (int argc, char **argv)
for (field = fields, num = 0, first = 1; field->name; field++, num++)
if (output_fields & (1 << (field - fields)))
{
- int sign = 0;
val_t val = vm_state_get_field (&state, field);
- if (repeats && field->change_type == CUMUL)
+ if (val < 0)
+ /* Couldn't fetch this field, don't try again. */
+ const_fields &= ~(1 << (field - fields));
+ else
{
- sign = 1;
- val -= vm_state_get_field (&prev_state, field);
- }
+ int sign = 0;
- PSEP (" ", 0);
- PVAL (val, field, fwidths[num], sign);
+ if (repeats && field->change_type == CUMUL)
+ {
+ sign = 1;
+ val -= vm_state_get_field (&prev_state, field);
+ }
+
+ PSEP (" ", 0);
+ PVAL (val, field, fwidths[num], sign);
+ }
}
putchar ('\n');
@@ -617,14 +624,17 @@ main (int argc, char **argv)
if (output_fields & (1 << (field - fields)))
{
val_t val = vm_state_get_field (&state, field);
- int fwidth = 0;
- if (print_prefix)
+ if (val >= 0)
{
- printf ("%s: ", field->name);
- fwidth = max_width - strlen (field->name);
+ int fwidth = 0;
+ if (print_prefix)
+ {
+ printf ("%s: ", field->name);
+ fwidth = max_width - strlen (field->name);
+ }
+ PVAL (val, field, fwidth, 0);
+ putchar ('\n');
}
- PVAL (val, field, fwidth, 0);
- putchar ('\n');
}
}