ftpd(8): drop some MINIX-specific changes

Also put in a crude way to clean up zombies when ftpd(8) is running
in daemon mode, because we do not yet support SA_NOCLDWAIT.

Change-Id: I8a7db1d665c432d736db833b0022d0340764db1f
This commit is contained in:
David van Moolenbroek 2017-03-05 16:13:32 +00:00
parent 340f5e5660
commit 5bded7c030

View File

@ -575,6 +575,15 @@ main(int argc, char *argv[])
syslog(LOG_ERR, "failed to write a pid file: %m"); syslog(LOG_ERR, "failed to write a pid file: %m");
for (;;) { for (;;) {
#ifdef __minix
/*
* MINIX 3 does not yet support SA_NOCLDWAIT. Cleaning
* up zombies this way is not perfect, but at least it
* prevents accumulation of zombies over time.
*/
while (waitpid(-1, NULL, WNOHANG) > 0)
;
#endif /* __minix */
if (poll(fds, n, INFTIM) == -1) { if (poll(fds, n, INFTIM) == -1) {
if (errno == EINTR) if (errno == EINTR)
continue; continue;
@ -708,7 +717,6 @@ main(int argc, char *argv[])
sa.sa_handler = toolong; sa.sa_handler = toolong;
(void) sigaction(SIGALRM, &sa, NULL); (void) sigaction(SIGALRM, &sa, NULL);
sa.sa_handler = sigurg; sa.sa_handler = sigurg;
#if !defined(__minix)
(void) sigaction(SIGURG, &sa, NULL); (void) sigaction(SIGURG, &sa, NULL);
/* Try to handle urgent data inline */ /* Try to handle urgent data inline */
@ -723,7 +731,6 @@ main(int argc, char *argv[])
sizeof(int)) < 0) sizeof(int)) < 0)
syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m"); syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
#endif #endif
#endif /* !defined(__minix) */
#ifdef F_SETOWN #ifdef F_SETOWN
if (fcntl(fileno(stdin), F_SETOWN, getpid()) == -1) if (fcntl(fileno(stdin), F_SETOWN, getpid()) == -1)
@ -2012,7 +2019,6 @@ dataconn(const char *name, off_t size, const char *fmode)
} }
(void) close(pdata); (void) close(pdata);
pdata = s; pdata = s;
#if !defined(__minix)
switch (from.su_family) { switch (from.su_family) {
case AF_INET: case AF_INET:
#ifdef IP_TOS #ifdef IP_TOS
@ -2024,7 +2030,6 @@ dataconn(const char *name, off_t size, const char *fmode)
break; break;
#endif #endif
} }
#endif /* !defined(__minix) */
/* Set keepalives on the socket to detect dropped conns. */ /* Set keepalives on the socket to detect dropped conns. */
#ifdef SO_KEEPALIVE #ifdef SO_KEEPALIVE
keepalive = 1; keepalive = 1;