summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2006-01-21 13:06:37 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2006-01-21 13:06:37 +0000
commita599a64a9f7c48b27f8f282e74569d35b1b3968b (patch)
tree2f35ab5470640302ea150d034cc0238fca6934fb /libexec
parentf014cff4cd6c5447d47b77c065f22c889ce47d21 (diff)
downloadsrc-test2-a599a64a9f7c48b27f8f282e74569d35b1b3968b.tar.gz
src-test2-a599a64a9f7c48b27f8f282e74569d35b1b3968b.zip
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpd.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index a5a60a421be9..60779b4ebef9 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -495,22 +495,29 @@ main(int argc, char *argv[], char **envp)
fd = accept(ctl_sock[i],
(struct sockaddr *)&his_addr,
&addrlen);
- if (fd >= 0) {
- if ((pid = fork()) == 0)
- break;
- else
- close(fd);
+ if (fd == -1) {
+ syslog(LOG_WARNING,
+ "accept: %m");
+ continue;
+ }
+ switch (pid = fork()) {
+ case 0:
+ /* child */
+ (void) dup2(fd, 0);
+ (void) dup2(fd, 1);
+ (void) close(fd);
+ for (i = 1; i <= *ctl_sock; i++)
+ close(ctl_sock[i]);
+ if (pfh != NULL)
+ pidfile_close(pfh);
+ goto gotchild;
+ case -1:
+ syslog(LOG_WARNING, "fork: %m");
+ /* FALLTHROUGH */
+ default:
+ close(fd);
}
}
- if (pid == 0) {
- /* child */
- (void) dup2(fd, 0);
- (void) dup2(fd, 1);
- close(ctl_sock[i]);
- if (pfh != NULL)
- pidfile_close(pfh);
- break;
- }
}
} else {
addrlen = sizeof(his_addr);
@@ -520,6 +527,7 @@ main(int argc, char *argv[], char **envp)
}
}
+gotchild:
sa.sa_handler = SIG_DFL;
(void)sigaction(SIGCHLD, &sa, NULL);