{
pid_t p;
struct event_desc ev;
- int i, check = 0;
+ int wstatus, i, check = 0;
char *msg;
/* NOTE: the memory used to return msg is leaked: use msgs in events only
case EVENT_CHILD:
/* See Stevens 5.10 */
- while ((p = waitpid(-1, NULL, WNOHANG)) != 0)
+ while ((p = waitpid(-1, &wstatus, WNOHANG)) != 0)
if (p == -1)
{
if (errno != EINTR)
if (daemon->tcp_pids[i] == p)
{
daemon->tcp_pids[i] = 0;
+
+ if (!WIFEXITED(wstatus))
+ {
+ /* If a helper process dies, (eg with SIGSEV)
+ log that and attempt to patch things up so that the
+ parent can continue to function. */
+ my_syslog(LOG_WARNING, _("TCP helper process %u died unexpectedly"), (unsigned int)p);
+ if (daemon->tcp_pipes[i] != -1)
+ {
+ close(daemon->tcp_pipes[i]);
+ daemon->tcp_pipes[i] = -1;
+ }
+ }
+
/* tcp_pipes == -1 && tcp_pids == 0 required to free slot */
if (daemon->tcp_pipes[i] == -1)
daemon->metrics[METRIC_TCP_CONNECTIONS]--;
Reset that here. */
if ((flags = fcntl(confd, F_GETFL, 0)) != -1)
while(retry_send(fcntl(confd, F_SETFL, flags & ~O_NONBLOCK)));
-
+
buff = tcp_request(confd, now, &tcp_addr, netmask, auth_dns);
if (buff)