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

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/* signalpipe.c
    23 *
     
    2021 */
    2122
    22 #include <unistd.h>
    23 #include <fcntl.h>
    24 #include <signal.h>
    25 #include <sys/types.h>
    26 #include <sys/socket.h>
    27 #include <sys/select.h>
     23#include "common.h"
    2824
    29 
    30 #include "signalpipe.h"
    31 #include "common.h"
    3225
    3326static int signal_pipe[2];
     
    3528static void signal_handler(int sig)
    3629{
    37     if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0)
    38         DEBUG(LOG_ERR, "Could not send signal: %m");
     30    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");
    3933}
    4034
     
    4438void udhcp_sp_setup(void)
    4539{
    46     socketpair(AF_UNIX, SOCK_STREAM, 0, signal_pipe);
     40    /* was socketpair, but it needs AF_UNIX in kernel */
     41    xpipe(signal_pipe);
    4742    fcntl(signal_pipe[0], F_SETFD, FD_CLOEXEC);
    4843    fcntl(signal_pipe[1], F_SETFD, FD_CLOEXEC);
     44    fcntl(signal_pipe[1], F_SETFL, O_NONBLOCK);
    4945    signal(SIGUSR1, signal_handler);
    5046    signal(SIGUSR2, signal_handler);
     
    7369int udhcp_sp_read(fd_set *rfds)
    7470{
    75     int sig;
     71    unsigned char sig;
    7672
    7773    if (!FD_ISSET(signal_pipe[0], rfds))
    7874        return 0;
    7975
    80     if (read(signal_pipe[0], &sig, sizeof(sig)) < 0)
     76    if (read(signal_pipe[0], &sig, 1) != 1)
    8177        return -1;
    8278
Note: See TracChangeset for help on using the changeset viewer.