Mercurial > masqmail
view src/libident/id_query.c @ 72:ad034b57f3b2
fixed Debian bug 536060 (log files are closed after SIGHUP receival)
Explanation:
When run in daemon mode, first the log files are opened. They get
assigned to the file descriptors 3 and 4 usually. Then std{in,out,err}
are closed. When SIGHUP comes in, all open files are closes and
masqmail reexecutes itself. The new masqmail instance opens the log
files at fd 0 and 1 now, but std{in,out,err} are closed afterwards,
thus the log files are closed.
The fix is to close the log files before std{in,out,err} are closed,
in case the log files have higher fds. After std{in,out,err} were
closed, the log files get opened again, now.
See also: http://bugs.debian.org/536060
author | meillo@marmaro.de |
---|---|
date | Wed, 16 Jun 2010 10:32:20 +0200 |
parents | 26e34ae9a3e3 |
children |
line wrap: on
line source
/* ** id_query.c Transmit a query to an IDENT server ** ** Author: Peter Eriksson <pen@lysator.liu.se> */ #ifdef NeXT3 # include <libc.h> #endif #include <stdio.h> #include <errno.h> #include <signal.h> #ifdef HAVE_ANSIHEADERS # include <stdlib.h> # include <string.h> # include <unistd.h> #endif #include <sys/types.h> #include <sys/wait.h> #include <sys/time.h> #ifdef _AIX # include <sys/select.h> #endif #ifdef _AIX # include <sys/select.h> #endif #ifdef VMS # include <sys/socket.h> /* for fd_set */ #endif #define IN_LIBIDENT_SRC #include "ident.h" /* int id_query __P4(ident_t *, id, int, lport, int, fport, struct timeval *, timeout) */ int id_query __P((ident_t * id, int lport, int fport, __STRUCT_TIMEVAL_P timeout)) { #ifdef SIGRETURNTYPE SIGRETURNTYPE(*old_sig) (); #else void (*old_sig) __P((int)); #endif int res; char buf[80]; fd_set ws; sprintf(buf, "%d , %d\r\n", lport, fport); if (timeout) { FD_ZERO(&ws); FD_SET(id->fd, &ws); #ifdef __hpux if ((res = select(FD_SETSIZE, (int *) 0, (int *) &ws, (int *) 0, timeout)) < 0) #else if ((res = select(FD_SETSIZE, (fd_set *) 0, &ws, (fd_set *) 0, timeout)) < 0) #endif return -1; if (res == 0) { errno = ETIMEDOUT; return -1; } } old_sig = signal(SIGPIPE, SIG_IGN); res = write(id->fd, buf, strlen(buf)); signal(SIGPIPE, old_sig); return res; }