udhcp: do not clobber errno by signal handler

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-02-16 20:04:19 +01:00
parent 5b3b468ec0
commit dc207f6696

View File

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