Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/networking/udhcp/signalpipe.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/networking/udhcp/signalpipe.c
r821 r1770 1 /* vi: set sw=4 ts=4: */ 1 2 /* signalpipe.c 2 3 * … … 20 21 */ 21 22 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" 28 24 29 30 #include "signalpipe.h"31 #include "common.h"32 25 33 26 static int signal_pipe[2]; … … 35 28 static void signal_handler(int sig) 36 29 { 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"); 39 33 } 40 34 … … 44 38 void udhcp_sp_setup(void) 45 39 { 46 socketpair(AF_UNIX, SOCK_STREAM, 0, signal_pipe); 40 /* was socketpair, but it needs AF_UNIX in kernel */ 41 xpipe(signal_pipe); 47 42 fcntl(signal_pipe[0], F_SETFD, FD_CLOEXEC); 48 43 fcntl(signal_pipe[1], F_SETFD, FD_CLOEXEC); 44 fcntl(signal_pipe[1], F_SETFL, O_NONBLOCK); 49 45 signal(SIGUSR1, signal_handler); 50 46 signal(SIGUSR2, signal_handler); … … 73 69 int udhcp_sp_read(fd_set *rfds) 74 70 { 75 intsig;71 unsigned char sig; 76 72 77 73 if (!FD_ISSET(signal_pipe[0], rfds)) 78 74 return 0; 79 75 80 if (read(signal_pipe[0], &sig, sizeof(sig)) < 0)76 if (read(signal_pipe[0], &sig, 1) != 1) 81 77 return -1; 82 78
Note:
See TracChangeset
for help on using the changeset viewer.