summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/pidof.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/procps/pidof.c b/procps/pidof.c
index f295617..86d1957 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -47,12 +47,13 @@ int pidof_main(int argc, char **argv)
}
#endif
/* Looks like everything is set to go. */
- while (optind < argc) {
+ argv += optind;
+ while (*argv) {
pid_t *pidList;
pid_t *pl;
/* reverse the pidlist like GNU pidof does. */
- pidList = pidlist_reverse(find_pid_by_name(argv[optind]));
+ pidList = pidlist_reverse(find_pid_by_name(*argv));
for (pl = pidList; *pl; pl++) {
#if ENABLE_FEATURE_PIDOF_OMIT
if (opt & OPT_OMIT) {
@@ -74,9 +75,10 @@ int pidof_main(int argc, char **argv)
#endif
}
free(pidList);
- optind++;
+ argv++;
}
- bb_putchar('\n');
+ if (!first)
+ bb_putchar('\n');
#if ENABLE_FEATURE_PIDOF_OMIT
if (ENABLE_FEATURE_CLEAN_UP)