On Thu, May 24, 2007 at 12:38:29PM +0200, Denis Vlasenko wrote:
> On 5/23/07, William Thompson <[EMAIL PROTECTED]> wrote:
> >I hate replying to myself.  I ran an strace on it as it started and it 
> >turns
> >out that there's no error checking on socketpair()
> >(networking/udhcp/signalpipe.c:39).  The stage that I'm running this didn't
> >have the unix module loaded so it was unable to open a socket.
> 
> Adding error check is trivial. But maybe we can use pipe instead of socket 
> pair?
> Can you test the following - just replace signalpipe.c with the following 
> code
> (// marks disabled code, non-indented lines is added code, the rest is
> unchaged):

My test case works fine.  I appreciate your assistance with the 2 problems
I've had.

Here's the diff between the two:

--- signalpipe.c-old    2007-03-22 16:21:23.000000000 -0400
+++ signalpipe.c        2007-05-24 08:22:09.000000000 -0400
@@ -27,7 +27,11 @@
 
 static void signal_handler(int sig)
 {
+#if 0
        if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0)
+#else
+       if (write(signal_pipe[1], &sig, sizeof(sig)) < 0)
+#endif
                bb_perror_msg("cannot send signal");
 }
 
@@ -36,9 +40,14 @@
  * and installs the signal handler */
 void udhcp_sp_setup(void)
 {
+#if 0
        socketpair(AF_UNIX, SOCK_STREAM, 0, signal_pipe);
+#endif
+       if (pipe(signal_pipe))
+               bb_perror_msg_and_die("pipe");
        fcntl(signal_pipe[0], F_SETFD, FD_CLOEXEC);
        fcntl(signal_pipe[1], F_SETFD, FD_CLOEXEC);
+       fcntl(signal_pipe[1], F_SETFL, O_NONBLOCK);
        signal(SIGUSR1, signal_handler);
        signal(SIGUSR2, signal_handler);
        signal(SIGTERM, signal_handler);
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to