diff options
author | Elliott Hughes <enh@google.com> | 2015-01-29 17:20:47 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-01-29 17:20:47 -0800 |
commit | b5fc3132eee1c3a783c566440d9132f792d10ec4 (patch) | |
tree | da6d62aca3369a42853ff00dd8a093df8b38749f | |
parent | d170bb035dc652b7e350ab7ccca0b1ffa332054e (diff) | |
download | system_core-b5fc3132eee1c3a783c566440d9132f792d10ec4.zip system_core-b5fc3132eee1c3a783c566440d9132f792d10ec4.tar.gz system_core-b5fc3132eee1c3a783c566440d9132f792d10ec4.tar.bz2 |
Add ps --ppid.
Needed for a libcore test.
Change-Id: Ia21ecf5f7bd8be7f1882d0014d7949d40f6841a5
-rw-r--r-- | toolbox/ps.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/toolbox/ps.c b/toolbox/ps.c index 7d6dfa0..d0a8db3 100644 --- a/toolbox/ps.c +++ b/toolbox/ps.c @@ -30,6 +30,7 @@ static char *nexttok(char **strp) #define SHOW_ABI 64 static int display_flags = 0; +static int ppid_filter = 0; static void print_exe_abi(int pid); @@ -145,6 +146,10 @@ static int ps_line(int pid, int tid, char *namefilter) strcpy(user,pw->pw_name); } + if(ppid_filter != 0 && ppid != ppid_filter) { + return 0; + } + if(!namefilter || !strncmp(cmdline[0] ? cmdline : name, namefilter, strlen(namefilter))) { if (display_flags & SHOW_MACLABEL) { fd = open(macline, O_RDONLY); @@ -266,6 +271,10 @@ int ps_main(int argc, char **argv) display_flags |= SHOW_CPU; } else if(!strcmp(argv[1],"--abi")) { display_flags |= SHOW_ABI; + } else if(!strcmp(argv[1],"--ppid")) { + ppid_filter = atoi(argv[2]); + argc--; + argv++; } else if(isdigit(argv[1][0])){ pidfilter = atoi(argv[1]); } else { |