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/udhcp/signalpipe.c

    r1765 r2725  
    11/* vi: set sw=4 ts=4: */
    2 /* signalpipe.c
    3  *
     2/*
    43 * Signal pipe infrastructure. A reliable way of delivering signals.
    54 *
     
    2019 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    2120 */
    22 
    2321#include "common.h"
    2422
    25 
    26 static int signal_pipe[2];
     23/* Global variable: we access it from signal handler */
     24static struct fd_pair signal_pipe;
    2725
    2826static void signal_handler(int sig)
    2927{
    3028    unsigned char ch = sig; /* use char, avoid dealing with partial writes */
    31     if (write(signal_pipe[1], &ch, 1) != 1)
    32         bb_perror_msg("cannot send signal");
     29    if (write(signal_pipe.wr, &ch, 1) != 1)
     30        bb_perror_msg("can't send signal");
    3331}
    34 
    3532
    3633/* Call this before doing anything else. Sets up the socket pair
    3734 * and installs the signal handler */
    38 void udhcp_sp_setup(void)
     35void FAST_FUNC udhcp_sp_setup(void)
    3936{
    4037    /* was socketpair, but it needs AF_UNIX in kernel */
    41     xpipe(signal_pipe);
    42     fcntl(signal_pipe[0], F_SETFD, FD_CLOEXEC);
    43     fcntl(signal_pipe[1], F_SETFD, FD_CLOEXEC);
    44     fcntl(signal_pipe[1], F_SETFL, O_NONBLOCK);
    45     signal(SIGUSR1, signal_handler);
    46     signal(SIGUSR2, signal_handler);
    47     signal(SIGTERM, signal_handler);
     38    xpiped_pair(signal_pipe);
     39    close_on_exec_on(signal_pipe.rd);
     40    close_on_exec_on(signal_pipe.wr);
     41    ndelay_on(signal_pipe.wr);
     42    bb_signals(0
     43        + (1 << SIGUSR1)
     44        + (1 << SIGUSR2)
     45        + (1 << SIGTERM)
     46        , signal_handler);
    4847}
    49 
    5048
    5149/* Quick little function to setup the rfds. Will return the
    5250 * max_fd for use with select. Limited in that you can only pass
    5351 * one extra fd */
    54 int udhcp_sp_fd_set(fd_set *rfds, int extra_fd)
     52int FAST_FUNC udhcp_sp_fd_set(fd_set *rfds, int extra_fd)
    5553{
    5654    FD_ZERO(rfds);
    57     FD_SET(signal_pipe[0], rfds);
     55    FD_SET(signal_pipe.rd, rfds);
    5856    if (extra_fd >= 0) {
    59         fcntl(extra_fd, F_SETFD, FD_CLOEXEC);
     57        close_on_exec_on(extra_fd);
    6058        FD_SET(extra_fd, rfds);
    6159    }
    62     return signal_pipe[0] > extra_fd ? signal_pipe[0] : extra_fd;
     60    return signal_pipe.rd > extra_fd ? signal_pipe.rd : extra_fd;
    6361}
    64 
    6562
    6663/* Read a signal from the signal pipe. Returns 0 if there is
    6764 * no signal, -1 on error (and sets errno appropriately), and
    6865 * your signal on success */
    69 int udhcp_sp_read(fd_set *rfds)
     66int FAST_FUNC udhcp_sp_read(const fd_set *rfds)
    7067{
    7168    unsigned char sig;
    7269
    73     if (!FD_ISSET(signal_pipe[0], rfds))
     70    if (!FD_ISSET(signal_pipe.rd, rfds))
    7471        return 0;
    7572
    76     if (read(signal_pipe[0], &sig, 1) != 1)
     73    if (safe_read(signal_pipe.rd, &sig, 1) != 1)
    7774        return -1;
    7875
Note: See TracChangeset for help on using the changeset viewer.