Changeset 1765 in MondoRescue for branches/2.2.5/mindi-busybox/init/halt.c


Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/init/halt.c

    r821 r1765  
    55 * Copyright 2006 by Rob Landley <rob@landley.net>
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPL version 2, see file LICENSE in this tarball for details.
    88 */
    99
    10 #include "busybox.h"
    11 #include <signal.h>
     10#include "libbb.h"
    1211#include <sys/reboot.h>
    13 #include <unistd.h>
    1412
    15 int halt_main(int argc, char *argv[])
     13int halt_main(int argc, char **argv);
     14int halt_main(int argc, char **argv)
    1615{
    1716    static const int magic[] = {
     
    2827RB_AUTOBOOT
    2928    };
    30     static const int signals[] = {SIGUSR1, SIGUSR2, SIGTERM};
     29    static const int signals[] = { SIGUSR1, SIGUSR2, SIGTERM };
    3130
    32     char *delay = "hpr";
     31    char *delay;
    3332    int which, flags, rc = 1;
    3433
    3534    /* Figure out which applet we're running */
    36     for(which=0;delay[which]!=*bb_applet_name;which++);
     35    for (which = 0; "hpr"[which] != *applet_name; which++);
    3736
    3837    /* Parse and handle arguments */
    39     flags = bb_getopt_ulflags(argc, argv, "d:nf", &delay);
    40     if (flags&1) sleep(atoi(delay));
    41     if (!(flags&2)) sync();
     38    flags = getopt32(argv, "d:nf", &delay);
     39    if (flags & 1) sleep(xatou(delay));
     40    if (!(flags & 2)) sync();
    4241
    4342    /* Perform action. */
    4443    if (ENABLE_INIT && !(flags & 4)) {
    4544        if (ENABLE_FEATURE_INITRD) {
    46             long *pidlist=find_pid_by_name("linuxrc");
    47             if (*pidlist>0) rc = kill(*pidlist,signals[which]);
    48             if (ENABLE_FEATURE_CLEAN_UP) free(pidlist);
     45            pid_t *pidlist = find_pid_by_name("linuxrc");
     46            if (pidlist[0] > 0)
     47                rc = kill(pidlist[0], signals[which]);
     48            if (ENABLE_FEATURE_CLEAN_UP)
     49                free(pidlist);
    4950        }
    50         if (rc) rc = kill(1,signals[which]);
    51     } else rc = reboot(magic[which]);
     51        if (rc)
     52            rc = kill(1, signals[which]);
     53    } else
     54        rc = reboot(magic[which]);
    5255
    53     if (rc) bb_error_msg("No.");
     56    if (rc)
     57        bb_error_msg("no");
    5458    return rc;
    5559}
Note: See TracChangeset for help on using the changeset viewer.