From 2a1da6e48c2079a4693e5d3416a0bf20b9731eaf Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 17 Oct 1996 15:26:58 +0000 Subject: (options, main): Add --top/-h option. --- utils/ps.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/ps.c b/utils/ps.c index 68f75558..06df9d92 100644 --- a/utils/ps.c +++ b/utils/ps.c @@ -80,6 +80,7 @@ static const struct argp_option options[] = {"sort", 's', "FIELD",0, "Sort the output with respect to FIELD," " backwards if FIELD is prefixed by `-'"}, {"threads", 'T', 0, 0, "Show the threads for each process"}, + {"top", 'h', "ENTRIES", OA, "Show the top ENTRIES processes (default 10)"}, {"tty", 't', "TTY", OA, "Only show processes with controlling" " terminal TTY"}, {0, 'u', 0, 0, "Use the `user' output-format"}, @@ -331,6 +332,7 @@ main(int argc, char *argv[]) int output_width = -1; /* Desired max output size. */ int show_non_hurd_procs = 1; /* Show non-hurd processes. */ int posix_fmt = 0; /* Use a posix_fmt-style format string. */ + int top = 0; /* Number of entries to output. */ /* Add a specific process to be printed out. */ void add_pid (unsigned pid) @@ -488,6 +490,7 @@ main(int argc, char *argv[]) case 'T': show_threads = TRUE; break; case 's': sort_key_name = arg; break; case 'r': sort_reverse = TRUE; break; + case 'h': top = arg ? atoi (arg) : 10; break; case 'F': fmt_string = arg; posix_fmt = 0; break; case 'o': fmt_string = arg; posix_fmt = 1; break; @@ -608,7 +611,7 @@ main(int argc, char *argv[]) psout (procset, fmt_string, posix_fmt, &ps_specs, sort_key_name, sort_reverse, output_width, print_heading, - squash_bogus_fields, squash_nominal_fields); + squash_bogus_fields, squash_nominal_fields, top); exit (0); } -- cgit v1.2.3