diff --git a/NEWS b/NEWS index 6a401b53..0d69cc7b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ procps-3.1.5 --> procps-3.1.6 +ps: new --ppid option selects by PPID watch: new --no-title option handle SPARC Linux badness rare crash fixed diff --git a/ps/common.h b/ps/common.h index 6cb6c14e..5cea9341 100644 --- a/ps/common.h +++ b/ps/common.h @@ -40,6 +40,7 @@ #define SEL_TTY 11 #define SEL_SESS 12 #define SEL_COMM 13 +#define SEL_PPID 14 /* Since an enum could be smashed by a #define, it would be bad. */ #define U98 0 /* Unix98 standard */ /* This must be 0 */ @@ -143,6 +144,7 @@ typedef union sel_union { pid_t pid; + pid_t ppid; uid_t uid; gid_t gid; dev_t tty; diff --git a/ps/display.c b/ps/display.c index b8475de6..bb791076 100644 --- a/ps/display.c +++ b/ps/display.c @@ -143,6 +143,7 @@ static void arg_show(void){ case SEL_FGID: show_gid("FGID", walk->n, walk->u); break; case SEL_PGRP: show_pid("PGRP", walk->n, walk->u); break; case SEL_PID : show_pid("PID ", walk->n, walk->u); break; + case SEL_PPID: show_pid("PPID", walk->n, walk->u); break; case SEL_TTY : show_tty("TTY ", walk->n, walk->u); break; case SEL_SESS: show_pid("SESS", walk->n, walk->u); break; case SEL_COMM: show_cmd("COMM", walk->n, walk->u); break; diff --git a/ps/help.c b/ps/help.c index 0b091a83..ab195aa8 100644 --- a/ps/help.c +++ b/ps/help.c @@ -30,7 +30,7 @@ const char *help_message = "r only running processes U processes for specified users\n" "x processes w/o controlling ttys t by tty\n" "*********** output format ********** *********** long options ***********\n" -"-o,o user-defined -f full --Group --User --pid --cols\n" +"-o,o user-defined -f full --Group --User --pid --cols --ppid\n" "-j,j job control s signal --group --user --sid --rows\n" "-O,O preloaded -o v virtual memory --cumulative --format --deselect\n" "-l,l long u user-oriented --sort --tty --forest --version\n" diff --git a/ps/parser.c b/ps/parser.c index a7ac4a71..6f250043 100644 --- a/ps/parser.c +++ b/ps/parser.c @@ -753,6 +753,7 @@ static const char *parse_gnu_option(void){ {"noheading", &&case_noheading}, {"noheadings", &&case_noheadings}, {"pid", &&case_pid}, + {"ppid", &&case_ppid}, {"rows", &&case_rows}, {"secsid", &&case_secsid}, {"sid", &&case_sid}, @@ -881,6 +882,14 @@ static const char *parse_gnu_option(void){ if(err) return err; selection_list->typecode = SEL_PID; return NULL; + case_ppid: + trace("--ppid\n"); + arg = grab_gnu_arg(); + if(!arg) return "List of process IDs must follow --ppid."; + err=parse_list(arg, parse_pid); + if(err) return err; + selection_list->typecode = SEL_PPID; + return NULL; case_rows: case_lines: trace("--rows\n"); diff --git a/ps/ps.1 b/ps/ps.1 index 4f2edc32..bcd0afd6 100644 --- a/ps/ps.1 +++ b/ps/ps.1 @@ -72,6 +72,7 @@ t select by tty --User select by real user name or ID --group select by effective group name or ID --pid select by process ID +--ppid select by parent process ID --sid select by session ID --tty select by terminal --user select by effective user name or ID diff --git a/ps/select.c b/ps/select.c index b582550c..aecc59d4 100644 --- a/ps/select.c +++ b/ps/select.c @@ -102,6 +102,7 @@ static int proc_was_listed(proc_t *buf){ break; case SEL_PGRP: return_if_match(pgrp,pid); break; case SEL_PID : return_if_match(pid,pid); + break; case SEL_PPID: return_if_match(ppid,ppid); break; case SEL_TTY : return_if_match(tty,tty); break; case SEL_SESS: return_if_match(session,pid);