diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2006-02-16 11:17:19 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2006-02-16 11:17:19 +0000 |
commit | df4f13b723bdd3b8b5912501b11a7854c08a58c7 (patch) | |
tree | a708cecdaf067dec6985d46baf69d6850c895719 /winsup | |
parent | 5e8b96517cb213e9cffb20c9e6be08a25de7f7ce (diff) | |
download | cygnal-df4f13b723bdd3b8b5912501b11a7854c08a58c7.tar.gz cygnal-df4f13b723bdd3b8b5912501b11a7854c08a58c7.tar.bz2 cygnal-df4f13b723bdd3b8b5912501b11a7854c08a58c7.zip |
* ps.cc (longopts): Add --process option.
(opts): Add -p option.
(usage): Mention -p/--process option.
(main): Handle -p option.
* utils.sgml: Describe -p/--process option.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/utils/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/utils/ps.cc | 15 | ||||
-rw-r--r-- | winsup/utils/utils.sgml | 5 |
3 files changed, 24 insertions, 4 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index adf2218b7..10fe823ea 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,11 @@ +2006-02-16 Jerry D. Hedden <jerry@hedden.us> + + * ps.cc (longopts): Add --process option. + (opts): Add -p option. + (usage): Mention -p/--process option. + (main): Handle -p option. + * utils.sgml: Describe -p/--process option. + 2006-02-15 Igor Peshansky <pechtcha@cs.nyu.edu> * regtool.cc (usage): Clarify help for "-K". diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc index 12b60fd08..27203d0c7 100644 --- a/winsup/utils/ps.cc +++ b/winsup/utils/ps.cc @@ -29,6 +29,7 @@ static struct option longopts[] = {"full", no_argument, NULL, 'f' }, {"help", no_argument, NULL, 'h' }, {"long", no_argument, NULL, 'l' }, + {"process", required_argument, NULL, 'p'}, {"summary", no_argument, NULL, 's' }, {"user", required_argument, NULL, 'u'}, {"version", no_argument, NULL, 'v'}, @@ -36,7 +37,7 @@ static struct option longopts[] = {NULL, 0, NULL, 0} }; -static char opts[] = "aefhlsu:vW"; +static char opts[] = "aefhlp:su:vW"; typedef BOOL (WINAPI *ENUMPROCESSMODULES)( HANDLE hProcess, // handle to the process @@ -200,7 +201,7 @@ static void usage (FILE * stream, int status) { fprintf (stream, "\ -Usage: %s [-aefls] [-u UID]\n\ +Usage: %s [-aefls] [-u UID] [-p PID]\n\ Report process status\n\ \n\ -a, --all show processes of all users\n\ @@ -208,6 +209,7 @@ Report process status\n\ -f, --full show process uids, ppids\n\ -h, --help output usage information and exit\n\ -l, --long show process uids, ppids, pgids, winpids\n\ + -p, --process show information for specified PID\n\ -s, --summary show process summary\n\ -u, --user list processes owned by UID\n\ -v, --version output version information and exit\n\ @@ -244,7 +246,7 @@ int main (int argc, char *argv[]) { external_pinfo *p; - int aflag, lflag, fflag, sflag, uid; + int aflag, lflag, fflag, sflag, uid, proc_id; cygwin_getinfo_types query = CW_GETPINFO; const char *dtitle = " PID TTY STIME COMMAND\n"; const char *dfmt = "%7d%4s%10s %s\n"; @@ -256,6 +258,7 @@ main (int argc, char *argv[]) aflag = lflag = fflag = sflag = 0; uid = getuid (); + proc_id = -1; lflag = 1; prog_name = strrchr (argv[0], '/'); @@ -281,6 +284,9 @@ main (int argc, char *argv[]) case 'l': lflag = 1; break; + case 'p': + proc_id = atoi (optarg); + break; case 's': sflag = 1; break; @@ -328,6 +334,9 @@ main (int argc, char *argv[]) (p = (external_pinfo *) cygwin_internal (query, pid | CW_NEXTPID)); pid = p->pid) { + if ((proc_id > 0) && (p->pid != proc_id)) + continue; + if (!aflag) if (p->version >= EXTERNAL_PINFO_VERSION_32_BIT) { diff --git a/winsup/utils/utils.sgml b/winsup/utils/utils.sgml index aad186962..de6ab52c4 100644 --- a/winsup/utils/utils.sgml +++ b/winsup/utils/utils.sgml @@ -970,6 +970,7 @@ Report process status -f, --full show process uids, ppids -h, --help output usage information and exit -l, --long show process uids, ppids, pgids, winpids + -p, --process show information for specified PID -s, --summary show process summary -u, --user list processes owned by UID -v, --version output version information and exit @@ -1008,7 +1009,9 @@ usernames for UIDs. The <literal>-l</literal> option is the default display mode, showing a "long" listing with all the above columns. The other display option is <literal>-s</literal>, which outputs a shorter listing of just PID, TTY, STIME, and COMMAND. The <literal>-u</literal> option allows you -to show only processes owned by a specific user. The <literal>-W</literal> +to show only processes owned by a specific user. The <literal>-p</literal> +option allows you to show information for only the process with the +specified PID. The <literal>-W</literal> option causes <command>ps</command> show non-Cygwin Windows processes as well as Cygwin processes. The WINPID is also the PID, and they can be killed with the Cygwin <command>kill</command> command's <literal>-f</literal> |