Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/procps/pidof.c


Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/procps/pidof.c

    r1765 r2725  
    55 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
    66 *
    7  * Licensed under the GPL version 2, see the file LICENSE in this tarball.
     7 * Licensed under GPLv2, see file LICENSE in this source tree.
    88 */
    99
     
    1111
    1212enum {
    13     USE_FEATURE_PIDOF_SINGLE(OPTBIT_SINGLE,)
    14     USE_FEATURE_PIDOF_OMIT(  OPTBIT_OMIT  ,)
    15     OPT_SINGLE = USE_FEATURE_PIDOF_SINGLE((1<<OPTBIT_SINGLE)) + 0,
    16     OPT_OMIT   = USE_FEATURE_PIDOF_OMIT(  (1<<OPTBIT_OMIT  )) + 0,
     13    IF_FEATURE_PIDOF_SINGLE(OPTBIT_SINGLE,)
     14    IF_FEATURE_PIDOF_OMIT(  OPTBIT_OMIT  ,)
     15    OPT_SINGLE = IF_FEATURE_PIDOF_SINGLE((1<<OPTBIT_SINGLE)) + 0,
     16    OPT_OMIT   = IF_FEATURE_PIDOF_OMIT(  (1<<OPTBIT_OMIT  )) + 0,
    1717};
    1818
    19 int pidof_main(int argc, char **argv);
    20 int pidof_main(int argc, char **argv)
     19int pidof_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     20int pidof_main(int argc UNUSED_PARAM, char **argv)
    2121{
    2222    unsigned first = 1;
    2323    unsigned opt;
    2424#if ENABLE_FEATURE_PIDOF_OMIT
    25     char ppid_str[sizeof(int)*3 + 1];
    2625    llist_t *omits = NULL; /* list of pids to omit */
    2726    opt_complementary = "o::";
     
    3029    /* do unconditional option parsing */
    3130    opt = getopt32(argv, ""
    32             USE_FEATURE_PIDOF_SINGLE ("s")
    33             USE_FEATURE_PIDOF_OMIT("o:", &omits));
     31            IF_FEATURE_PIDOF_SINGLE ("s")
     32            IF_FEATURE_PIDOF_OMIT("o:", &omits));
    3433
    3534#if ENABLE_FEATURE_PIDOF_OMIT
     
    3736    {
    3837        llist_t *omits_p = omits;
    39         while (omits_p) {
     38        while (1) {
     39            omits_p = llist_find_str(omits_p, "%PPID");
     40            if (!omits_p)
     41                break;
    4042            /* are we asked to exclude the parent's process ID?  */
    41             if (strcmp(omits_p->data, "%PPID") == 0) {
    42                 sprintf(ppid_str, "%u", (unsigned)getppid());
    43                 omits_p->data = ppid_str;
    44             }
    45             omits_p = omits_p->link;
     43            omits_p->data = utoa((unsigned)getppid());
    4644        }
    4745    }
    4846#endif
    4947    /* Looks like everything is set to go.  */
    50     while (optind < argc) {
     48    argv += optind;
     49    while (*argv) {
    5150        pid_t *pidList;
    5251        pid_t *pl;
    5352
    5453        /* reverse the pidlist like GNU pidof does.  */
    55         pidList = pidlist_reverse(find_pid_by_name(argv[optind]));
     54        pidList = pidlist_reverse(find_pid_by_name(*argv));
    5655        for (pl = pidList; *pl; pl++) {
    5756#if ENABLE_FEATURE_PIDOF_OMIT
     
    5958                llist_t *omits_p = omits;
    6059                while (omits_p) {
    61                     if (xatoul(omits_p->data) == *pl) {
     60                    if (xatoul(omits_p->data) == (unsigned long)(*pl)) {
    6261                        goto omitting;
    6362                    }
     
    7574        }
    7675        free(pidList);
    77         optind++;
     76        argv++;
    7877    }
    79     putchar('\n');
     78    if (!first)
     79        bb_putchar('\n');
    8080
    8181#if ENABLE_FEATURE_PIDOF_OMIT
Note: See TracChangeset for help on using the changeset viewer.