]> git.itanic.dy.fi Git - scan-pagemap/blobdiff - parse.c
Add support for parsing multiple pid numbers
[scan-pagemap] / parse.c
diff --git a/parse.c b/parse.c
index 76b0eec7c81ccf54f81542eab9ed78acf47afc23..1170bab12e0ad7d081e69146d6b473a4c38ba91b 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -151,6 +151,7 @@ static char *get_name_by_pid(int pid)
 
 static int should_scan_process(struct parse_opts *opts, struct process *process)
 {
+       struct pidlist *pid;
        int match = 0;
        char *name;
 
@@ -161,8 +162,12 @@ static int should_scan_process(struct parse_opts *opts, struct process *process)
        }
 
        if (is_parse_option(opts, PARSE_PID)) {
-               if (opts->pid == process->pid)
-                       match = 1;
+               list_for_each_entry(pid, &opts->pidlist, list) {
+                       if (pid->pid == process->pid) {
+                               match = 1;
+                               break;
+                       }
+               }
        }
 
        if (is_parse_option(opts, PARSE_MAP_NAME))
@@ -467,6 +472,7 @@ static int read_pageframe_with_threads(int pid,
 int scan_all_pids(struct pageframe *pf, struct process *process_list,
                struct parse_opts *opts)
 {
+       struct pidlist *pidlist;
        DIR *dir = NULL;
        int pid;
        int count = 0;
@@ -480,9 +486,12 @@ int scan_all_pids(struct pageframe *pf, struct process *process_list,
                dir = NULL;
        }
 
-       if (is_parse_option(opts, PARSE_PID))
-               count = read_pageframe_with_threads(opts->pid, pf, process_list,
-                                               opts);
+       if (is_parse_option(opts, PARSE_PID)) {
+               list_for_each_entry(pidlist, &opts->pidlist, list) {
+                       count += read_pageframe_with_threads(pidlist->pid, pf,
+                                                       process_list, opts);
+               }
+       }
 
        if ((count == 0) && !(is_parse_option(opts, PARSE_MAP_NAME))) {
                printf("Failed to find any matching processes "