masqmail
view src/libident/support.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 | 08114f7dcc23 |
children |
line source
1 /*
2 ** support.c
3 **
4 ** Author: Pr Emanuelsson <pell@lysator.liu.se>
5 ** Hacked by: Peter Eriksson <pen@lysator.liu.se>
6 */
7 #include <stdio.h>
8 #include <ctype.h>
10 #ifdef HAVE_ANSIHEADERS
11 # include <stdlib.h>
12 # include <string.h>
13 #else
14 # define strchr(str, c) index(str, c)
15 #endif
17 #define IN_LIBIDENT_SRC
18 #include "ident.h"
21 char*
22 id_strdup __P1(char *, str)
23 {
24 char *cp;
26 cp = (char *) malloc(strlen(str) + 1);
27 if (cp == NULL) {
28 #ifdef DEBUG
29 perror("libident: malloc");
30 #endif
31 return NULL;
32 }
34 strcpy(cp, str);
36 return cp;
37 }
40 char*
41 id_strtok __P3(char *, cp, char *, cs, char *, dc)
42 {
43 static char *bp = 0;
45 if (cp)
46 bp = cp;
48 /*
49 ** No delimitor cs - return whole buffer and point at end
50 */
51 if (!cs) {
52 while (*bp)
53 bp++;
54 return cs;
55 }
57 /*
58 ** Skip leading spaces
59 */
60 while (isspace(*bp))
61 bp++;
63 /*
64 ** No token found?
65 */
66 if (!*bp)
67 return 0;
69 cp = bp;
70 while (*bp && !strchr(cs, *bp))
71 bp++;
73 /*
74 ** Remove trailing spaces
75 */
76 *dc = *bp;
77 for (dc = bp - 1; dc > cp && isspace(*dc); dc--);
78 *++dc = '\0';
80 bp++;
82 return cp;
83 }