Mercurial > masqmail
comparison src/listen.c @ 15:f671821d8222
code beautifying; 0 -> \0 if appropriate
author | meillo@marmaro.de |
---|---|
date | Thu, 06 Nov 2008 09:18:38 +0100 |
parents | 26e34ae9a3e3 |
children | 5745edd5b769 |
comparison
equal
deleted
inserted
replaced
14:a8f3424347dc | 15:f671821d8222 |
---|---|
14 You should have received a copy of the GNU General Public License | 14 You should have received a copy of the GNU General Public License |
15 along with this program; if not, write to the Free Software | 15 along with this program; if not, write to the Free Software |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 */ | 17 */ |
18 | 18 |
19 #include "masqmail.h" | |
20 #include <sys/wait.h> | 19 #include <sys/wait.h> |
21 #include <sys/types.h> | 20 #include <sys/types.h> |
21 | |
22 #include "masqmail.h" | |
22 | 23 |
23 static int volatile sighup_seen = 0; | 24 static int volatile sighup_seen = 0; |
24 | 25 |
25 static void | 26 static void |
26 sighup_handler(int sig) | 27 sighup_handler(int sig) |
130 | 131 |
131 /* setup handler for HUP signal: */ | 132 /* setup handler for HUP signal: */ |
132 signal(SIGHUP, sighup_handler); | 133 signal(SIGHUP, sighup_handler); |
133 signal(SIGCHLD, sigchld_handler); | 134 signal(SIGCHLD, sigchld_handler); |
134 | 135 |
135 /* now that we have our socket(s), | 136 /* now that we have our socket(s), we can give up root privileges */ |
136 we can give up root privileges */ | |
137 if (!conf.run_as_user) { | 137 if (!conf.run_as_user) { |
138 if (setegid(conf.mail_gid) != 0) { | 138 if (setegid(conf.mail_gid) != 0) { |
139 logwrite(LOG_ALERT, "could not change gid to %d: %s\n", conf.mail_gid, strerror(errno)); | 139 logwrite(LOG_ALERT, "could not change gid to %d: %s\n", conf.mail_gid, strerror(errno)); |
140 exit(EXIT_FAILURE); | 140 exit(EXIT_FAILURE); |
141 } | 141 } |
170 if (tm.tv_sec < 0) | 170 if (tm.tv_sec < 0) |
171 tm.tv_sec = 0; | 171 tm.tv_sec = 0; |
172 } | 172 } |
173 } | 173 } |
174 /* Block until input arrives on one or more active sockets, | 174 /* Block until input arrives on one or more active sockets, |
175 or signal arrives, | 175 or signal arrives, or queuing interval time elapsed (if qival > 0) */ |
176 or queuing interval time elapsed (if qival > 0) */ | |
177 read_fd_set = active_fd_set; | 176 read_fd_set = active_fd_set; |
178 if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) { | 177 if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) { |
179 if (errno != EINTR) { | 178 if (errno != EINTR) { |
180 logwrite(LOG_ALERT, "select: (terminating): %s\n", strerror(errno)); | 179 logwrite(LOG_ALERT, "select: (terminating): %s\n", strerror(errno)); |
181 exit(EXIT_FAILURE); | 180 exit(EXIT_FAILURE); |