From a692e4fc423a0fabe2bef02b6a6dd21c9afde339 Mon Sep 17 00:00:00 2001 From: yar Date: Sat, 21 Jan 2006 12:34:28 +0000 Subject: The daemon's child shouldn't go on with the for loop over ctl_sock's -- it is solely the parent daemon's job. So just break out of the loop in the child. MFC after: 5 days --- libexec/ftpd/ftpd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libexec/ftpd/ftpd.c') diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 9590f78..a5a60a4 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -496,16 +496,17 @@ main(int argc, char *argv[], char **envp) (struct sockaddr *)&his_addr, &addrlen); if (fd >= 0) { - if ((pid = fork()) == 0) { - /* child */ - (void) dup2(fd, 0); - (void) dup2(fd, 1); - close(ctl_sock[i]); - } else + if ((pid = fork()) == 0) + break; + else 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; -- cgit v1.1