mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Remove the NO_FORK compile-time option, and support for uclinux.
In an era where everything has an MMU, this looks like an anachronism, and it adds to (Ok, multiplies!) the combinatorial explosion of compile-time options.
This commit is contained in:
@@ -485,7 +485,6 @@ int main (int argc, char **argv)
|
||||
if (chdir("/") != 0)
|
||||
die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
|
||||
|
||||
#ifndef NO_FORK
|
||||
if (!option_bool(OPT_NO_FORK))
|
||||
{
|
||||
pid_t pid;
|
||||
@@ -525,7 +524,6 @@ int main (int argc, char **argv)
|
||||
if (pid != 0)
|
||||
_exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* write pidfile _after_ forking ! */
|
||||
if (daemon->runfile)
|
||||
@@ -1628,12 +1626,10 @@ static int set_dns_listeners(time_t now)
|
||||
|
||||
}
|
||||
|
||||
#ifndef NO_FORK
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
for (i = 0; i < MAX_PROCS; i++)
|
||||
if (daemon->tcp_pipes[i] != -1)
|
||||
poll_listen(daemon->tcp_pipes[i], POLLIN);
|
||||
#endif
|
||||
|
||||
return wait;
|
||||
}
|
||||
@@ -1643,9 +1639,7 @@ static void check_dns_listeners(time_t now)
|
||||
struct serverfd *serverfdp;
|
||||
struct listener *listener;
|
||||
int i;
|
||||
#ifndef NO_FORK
|
||||
int pipefd[2];
|
||||
#endif
|
||||
|
||||
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
|
||||
if (poll_check(serverfdp->fd, POLLIN))
|
||||
@@ -1657,7 +1651,6 @@ static void check_dns_listeners(time_t now)
|
||||
poll_check(daemon->randomsocks[i].fd, POLLIN))
|
||||
reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
|
||||
|
||||
#ifndef NO_FORK
|
||||
/* Races. The child process can die before we read all of the data from the
|
||||
pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
|
||||
process, and tcp_pipes to -1 and close the FD when we read the last
|
||||
@@ -1674,7 +1667,6 @@ static void check_dns_listeners(time_t now)
|
||||
close(daemon->tcp_pipes[i]);
|
||||
daemon->tcp_pipes[i] = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (listener = daemon->listeners; listener; listener = listener->next)
|
||||
{
|
||||
@@ -1768,7 +1760,6 @@ static void check_dns_listeners(time_t now)
|
||||
shutdown(confd, SHUT_RDWR);
|
||||
while (retry_send(close(confd)));
|
||||
}
|
||||
#ifndef NO_FORK
|
||||
else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
|
||||
{
|
||||
close(pipefd[1]); /* parent needs read pipe end. */
|
||||
@@ -1791,7 +1782,6 @@ static void check_dns_listeners(time_t now)
|
||||
/* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
|
||||
daemon->log_id += TCP_MAX_QUERIES;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
unsigned char *buff;
|
||||
@@ -1811,7 +1801,6 @@ static void check_dns_listeners(time_t now)
|
||||
auth_dns = 0;
|
||||
}
|
||||
|
||||
#ifndef NO_FORK
|
||||
/* Arrange for SIGALRM after CHILD_LIFETIME seconds to
|
||||
terminate the process. */
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
@@ -1820,7 +1809,6 @@ static void check_dns_listeners(time_t now)
|
||||
close(pipefd[0]); /* close read end in child. */
|
||||
daemon->pipe_to_parent = pipefd[1];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* start with no upstream connections. */
|
||||
for (s = daemon->servers; s; s = s->next)
|
||||
@@ -1846,13 +1834,11 @@ static void check_dns_listeners(time_t now)
|
||||
shutdown(s->tcpfd, SHUT_RDWR);
|
||||
while (retry_send(close(s->tcpfd)));
|
||||
}
|
||||
#ifndef NO_FORK
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
{
|
||||
flush_log();
|
||||
_exit(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user