Skip to content

Commit 37df4f9

Browse files
committed
Merge pull request #41 from mslusarz/master
Let multiple -c options
2 parents 7f4f6ce + 1657448 commit 37df4f9

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

cv.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ char *proc_names[] = {"cp", "mv", "dd", "tar", "gzip", "gunzip", "cat",
4949
"sha224sum", "sha256sum", "sha384sum", "sha512sum", NULL
5050
};
5151

52-
char *proc_specifiq_name = NULL;
52+
static int proc_specifiq_name_cnt;
53+
static char **proc_specifiq_name;
54+
5355
pid_t proc_specifiq_pid = 0;
5456
signed char flag_quiet = 0;
5557
signed char flag_debug = 0;
@@ -386,7 +388,9 @@ while(1) {
386388
break;
387389

388390
case 'c':
389-
proc_specifiq_name = strdup(optarg);
391+
proc_specifiq_name_cnt++;
392+
proc_specifiq_name = realloc(proc_specifiq_name, proc_specifiq_name_cnt * sizeof(proc_specifiq_name[0]));
393+
proc_specifiq_name[proc_specifiq_name_cnt - 1] = strdup(optarg);
390394
break;
391395

392396
case 'p':
@@ -481,10 +485,11 @@ signed char search_all = 1;
481485

482486
pid_count = 0;
483487

484-
if (proc_specifiq_name) {
485-
pid_count += find_pids_by_binary_name(proc_specifiq_name,
486-
pidinfo_list + pid_count,
487-
MAX_PIDS - pid_count);
488+
if (proc_specifiq_name_cnt) {
489+
for (i = 0; i < proc_specifiq_name_cnt; ++i)
490+
pid_count += find_pids_by_binary_name(proc_specifiq_name[i],
491+
pidinfo_list + pid_count,
492+
MAX_PIDS - pid_count);
488493
search_all = 0;
489494
}
490495

0 commit comments

Comments
 (0)