diff options
Diffstat (limited to 'utils/psout.c')
-rw-r--r-- | utils/psout.c | 16 |
1 files changed, 14 insertions, 2 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) |