From 2173fcb597eea4896f1ee9adb551a89f4827dedd Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 27 May 1997 19:08:08 +0000 Subject: (main): Correct filtering of process-owners when processes are explicitly specified. Don't use ARGS_DOC. (args_doc): Variable removed. --- utils/ps.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'utils/ps.c') diff --git a/utils/ps.c b/utils/ps.c index d5f06efd..ae6eeec6 100644 --- a/utils/ps.c +++ b/utils/ps.c @@ -98,8 +98,7 @@ static const struct argp_option options[] = {0, 0} }; -char *args_doc = "[PID...]"; -char *doc = +static const char doc[] = "Show information about processes PID... (default all `interesting' processes)" "\vThe USER, LID, PID, PGRP, and SID arguments may also be comma separated" " lists. The System V options -u and -g may be accessed with -O and -G."; @@ -335,7 +334,7 @@ main(int argc, char *argv[]) { { &pids_argp, 0, "Process selection (before filtering; default is all processes):", 3}, {0} }; - struct argp argp = { options, parse_opt, args_doc, doc, argp_kids }; + struct argp argp = { options, parse_opt, 0, doc, argp_kids }; err = ps_context_create (getproc (), &context); if (err) @@ -344,16 +343,6 @@ main(int argc, char *argv[]) /* Parse our command line. This shouldn't ever return an error. */ argp_parse (&argp, argc, argv, 0, 0, 0); - if (only_uids->num == 0 && (filter_mask & FILTER_OWNER)) - /* Restrict the output to only our own processes. */ - { - int uid = getuid (); - if (uid >= 0) - add_uid (uid, 0); - else - filter_mask &= ~FILTER_OWNER; /* Must be an anonymous process. */ - } - /* Select an explicit format string if FMT_STRING is a format name. */ { const char *fmt_name (unsigned n) @@ -411,6 +400,16 @@ main(int argc, char *argv[]) if (no_msg_port) proc_stat_list_set_flags(procset, PSTAT_NO_MSGPORT); + if (only_uids->num == 0 && (filter_mask & FILTER_OWNER)) + /* Restrict the output to only our own processes. */ + { + int uid = getuid (); + if (uid >= 0) + add_uid (uid, 0); + else + filter_mask &= ~FILTER_OWNER; /* Must be an anonymous process. */ + } + /* Filter out any processes that we don't want to show. */ if (only_uids->num || not_uids->num) proc_stat_list_filter1 (procset, proc_stat_owner_ok, -- cgit v1.2.3