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/networking/slattach.c

    r1765 r2725  
    55 * Author: Ignacio Garcia Perez (iggarpe at gmail dot com)
    66 *
    7  * License: GPLv2 or later, see LICENSE file in this tarball.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 *
    99 * There are some differences from the standard net-tools slattach:
     
    2121    int saved_disc;
    2222    struct termios saved_state;
    23 };
     23} FIX_ALIASING;
    2424#define G (*(struct globals*)&bb_common_bufsiz1)
    2525#define handle       (G.handle      )
    2626#define saved_disc   (G.saved_disc  )
    2727#define saved_state  (G.saved_state )
    28 #define INIT_G() do {} while (0)
     28#define INIT_G() do { } while (0)
    2929
    3030
     
    4444}
    4545
    46 static int set_termios_state_and_warn(struct termios *state)
     46static int set_termios_state_or_warn(struct termios *state)
    4747{
    4848    int ret;
     
    6565 * as possible.
    6666 */
    67 static void restore_state_and_exit(int exitcode) ATTRIBUTE_NORETURN;
     67static void restore_state_and_exit(int exitcode) NORETURN;
    6868static void restore_state_and_exit(int exitcode)
    6969{
     
    7979    cfsetispeed(&state, B0);
    8080    cfsetospeed(&state, B0);
    81     if (set_termios_state_and_warn(&state))
     81    if (set_termios_state_or_warn(&state))
    8282        exitcode = 1;
    8383    sleep(1);
    8484
    8585    /* Restore line status */
    86     if (set_termios_state_and_warn(&saved_state))
     86    if (set_termios_state_or_warn(&saved_state))
    8787        exit(EXIT_FAILURE);
    8888    if (ENABLE_FEATURE_CLEAN_UP)
     
    100100
    101101    /* Set line status */
    102     if (set_termios_state_and_warn(state))
     102    if (set_termios_state_or_warn(state))
    103103        goto bad;
    104104    /* Set line discliple (N_SLIP always) */
     
    111111    if (ioctl_or_warn(handle, SIOCSIFENCAP, &encap) < 0) {
    112112 bad:
    113         restore_state_and_exit(1);
    114     }
    115 }
    116 
    117 static void sig_handler(int signo)
    118 {
    119     restore_state_and_exit(0);
    120 }
    121 
    122 int slattach_main(int argc, char **argv);
    123 int slattach_main(int argc, char **argv)
     113        restore_state_and_exit(EXIT_FAILURE);
     114    }
     115}
     116
     117static void sig_handler(int signo UNUSED_PARAM)
     118{
     119    restore_state_and_exit(EXIT_SUCCESS);
     120}
     121
     122int slattach_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     123int slattach_main(int argc UNUSED_PARAM, char **argv)
    124124{
    125125    /* Line discipline code table */
     
    135135    struct termios state;
    136136    const char *proto = "cslip";
    137     const char *extcmd;             /* Command to execute after hangup */
     137    const char *extcmd;   /* Command to execute after hangup */
    138138    const char *baud_str;
    139     int baud_code = -1;             /* Line baud rate (system code) */
     139    int baud_code = -1;   /* Line baud rate (system code) */
    140140
    141141    enum {
     
    176176    /* Trap signals in order to restore tty states upon exit */
    177177    if (!(opt & OPT_e_quit)) {
    178         signal(SIGHUP, sig_handler);
    179         signal(SIGINT, sig_handler);
    180         signal(SIGQUIT, sig_handler);
    181         signal(SIGTERM, sig_handler);
     178        bb_signals(0
     179            + (1 << SIGHUP)
     180            + (1 << SIGINT)
     181            + (1 << SIGQUIT)
     182            + (1 << SIGTERM)
     183            , sig_handler);
    182184    }
    183185
     
    205207                      | ((opt & OPT_L_local) ? CLOCAL : 0)
    206208                      | ((opt & OPT_F_noflow) ? 0 : CRTSCTS);
     209        cfsetispeed(&state, cfgetispeed(&saved_state));
     210        cfsetospeed(&state, cfgetospeed(&saved_state));
    207211    }
    208212
     
    238242
    239243    /* Restore states and exit */
    240     restore_state_and_exit(0);
    241 }
     244    restore_state_and_exit(EXIT_SUCCESS);
     245}
Note: See TracChangeset for help on using the changeset viewer.