diff options
author | Miles Bader <miles@gnu.org> | 1996-10-17 15:25:47 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-10-17 15:25:47 +0000 |
commit | 3d74b5c10650f07d510792f90ecaa4bcae1fd896 (patch) | |
tree | ca1de4b2b311f77dbce169e7cc45b7eff9e7c333 /utils | |
parent | 43adb5c2b1e1bd8c32961524e769a458c660ef11 (diff) |
(psout):
Add TOP parameter.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/psout.c | 16 | ||||
-rw-r--r-- | utils/psout.h | 3 |
2 files changed, 16 insertions, 3 deletions
diff --git a/utils/psout.c b/utils/psout.c index 7f2b0591..805131f9 100644 --- a/utils/psout.c +++ b/utils/psout.c @@ -31,7 +31,8 @@ psout (struct proc_stat_list *procs, char *fmt_string, int posix_fmt, struct ps_fmt_specs *specs, char *sort_key_name, int sort_reverse, int output_width, int print_heading, - int squash_bogus_fields, int squash_nominal_fields) + int squash_bogus_fields, int squash_nominal_fields, + int top) { error_t err; struct ps_stream *output; @@ -96,7 +97,7 @@ psout (struct proc_stat_list *procs, error (5, err, "Can't make output stream"); if (print_heading) - if (proc_stat_list_num_procs (procs) > 0) + if (procs->num_procs > 0) { err = ps_fmt_write_titles (fmt, output); if (err) @@ -117,6 +118,17 @@ psout (struct proc_stat_list *procs, ps_fmt_set_output_width (fmt, output_width); } + if (top) + /* Restrict output to the top TOP entries. */ + { + int remove = 0; + int filter (struct proc_stat *ps) + { + return --top >= 0; + } + proc_stat_list_filter1 (procs, filter, 0, 0); + } + /* Finally, output all the processes! */ err = proc_stat_list_fmt (procs, fmt, output); if (err) diff --git a/utils/psout.h b/utils/psout.h index f9c44484..06f15d73 100644 --- a/utils/psout.h +++ b/utils/psout.h @@ -27,6 +27,7 @@ void psout (struct proc_stat_list *procs, char *fmt_string, int posix_fmt, struct ps_fmt_specs *specs, char *sort_key_name, int sort_reverse, int output_width, int print_heading, - int squash_bogus_fields, int squash_nominal_fields); + int squash_bogus_fields, int squash_nominal_fields, + int top); #endif /* __PSOUT_H__ */ |