Now that we have code in place for scanning multiple pid numbers, we
can also convert all process names to pids. That way, it becomes also
possible to add all process names user has given as an argument.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
#include "parse.h"
#include "analyze.h"
#include "parse.h"
#include "analyze.h"
void print_help_and_die(char *name)
{
void print_help_and_die(char *name)
{
#define OPT_WITH_THREADS 0x101
#define OPT_WITH_THREADS 0x101
+static void get_all_pids_by_name(struct parse_opts *opts, char *name)
+{
+ struct pidlist *pidlist;
+ DIR *dir = NULL;
+ int pid;
+
+ while ((pid = get_next_pid_by_name(&dir, name))) {
+ pidlist = alloc_pidlist();
+ if (pidlist == NULL)
+ return;
+ pidlist->pid = pid;
+ list_add_tail(&pidlist->list, &opts->pidlist);
+ }
+}
+
void read_args(int argc, char *argv[], struct parse_opts *opts)
{
int optind = 0, c;
void read_args(int argc, char *argv[], struct parse_opts *opts)
{
int optind = 0, c;
- opts->parse_mask |= PARSE_PROCESS_NAME;
- opts->name = optarg;
+ get_all_pids_by_name(opts, optarg);
+ opts->parse_mask |= PARSE_PID;
break;
case 'm':
opts->parse_mask |= PARSE_MAP_NAME;
break;
case 'm':
opts->parse_mask |= PARSE_MAP_NAME;