Vladimir N. Oleynik writes:
[oweals/busybox.git] / procps / pidof.c
index d0d65e0db308e63295944c9807718268b777b1b2..2fe8ecd25b66e952ab7844b5b38dbd3531198ddf 100644 (file)
@@ -2,8 +2,7 @@
 /*
  * pidof implementation for busybox
  *
- * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
- * Copyright (C) 1999-2002 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -46,29 +45,25 @@ extern int pidof_main(int argc, char **argv)
                                single_flag = 1;
                                break;
                        default:
-                               show_usage();
+                               bb_show_usage();
                }
        }
 
        /* Looks like everything is set to go. */
        while(optind < argc) {
-               long* pidList;
+               long *pidList;
+               long *pl;
 
-               pidList = find_pid_by_name( argv[optind]);
-               if (!pidList || *pidList<=0) {
-                       break;
-               }
-
-               for(; pidList && *pidList!=0; pidList++) {
-                       printf("%s%ld", (n++ ? " " : ""), (long)*pidList);
+               pidList = find_pid_by_name(argv[optind]);
+               for(pl = pidList; *pl > 0; pl++) {
+                       printf("%s%ld", (n++ ? " " : ""), *pl);
                        fail = 0;
                        if (single_flag)
                                break;
                }
-               /* Note that we don't bother to free the memory
-                * allocated in find_pid_by_name().  It will be freed
-                * upon exit, so we can save a byte or two */
+               free(pidList);
                optind++;
+
        }
        printf("\n");