udhcp: do not clobber errno by signal handler
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 16 Feb 2017 19:04:19 +0000 (20:04 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 16 Feb 2017 19:04:19 +0000 (20:04 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/signalpipe.c

index 6355c5e90208b5c5f7b70ba74d20bcfd1b510dd5..30bccd6bf9cb3aedf1f07970119c85e7b18b2a80 100644 (file)
@@ -25,9 +25,11 @@ static struct fd_pair signal_pipe;
 
 static void signal_handler(int sig)
 {
+       int sv = errno;
        unsigned char ch = sig; /* use char, avoid dealing with partial writes */
        if (write(signal_pipe.wr, &ch, 1) != 1)
                bb_perror_msg("can't send signal");
+       errno = sv;
 }
 
 /* Call this before doing anything else. Sets up the socket pair