SCCS-vsn: libexec/ftpd/ftpd.c 4.8
struct servent *sp;
int lostconn();
struct servent *sp;
int lostconn();
FILE *getdatasock(), *dataconn();
char *ntoa();
FILE *getdatasock(), *dataconn();
char *ntoa();
char *argv[];
{
int ctrl, s, options = 0;
char *argv[];
{
int ctrl, s, options = 0;
char *cp;
sp = getservbyname("ftp", "tcp");
char *cp;
sp = getservbyname("ftp", "tcp");
perror("ftpd: socket");
sleep(5);
}
perror("ftpd: socket");
sleep(5);
}
+ if (options & SO_DEBUG)
+ if (setsockopt(s, SOL_SOCKET, SO_DEBUG, 0, 0) < 0)
+ perror("ftpd: setsockopt (SO_DEBUG)");
+#ifdef notdef
+ if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, 0, 0) < 0)
+ perror("ftpd: setsockopt (SO_KEEPALIVE)");
+#endif
while (bind(s, &ctrl_addr, sizeof (ctrl_addr), 0) < 0) {
perror("ftpd: bind");
sleep(5);
}
while (bind(s, &ctrl_addr, sizeof (ctrl_addr), 0) < 0) {
perror("ftpd: bind");
sleep(5);
}
+ signal(SIGCHLD, reapchild);
listen(s, 10);
for (;;) {
int hisaddrlen = sizeof (his_addr);
ctrl = accept(s, &his_addr, &hisaddrlen, 0);
if (ctrl < 0) {
listen(s, 10);
for (;;) {
int hisaddrlen = sizeof (his_addr);
ctrl = accept(s, &his_addr, &hisaddrlen, 0);
if (ctrl < 0) {
+ if (errno == EINTR)
+ continue;
continue;
}
if (fork() == 0) {
continue;
}
if (fork() == 0) {
- while (wait3(status, WNOHANG, 0) > 0)
- continue;
+reapchild()
+{
+ union wait status;
+
+ while (wait3(&status, WNOHANG, 0) > 0)
+ ;
+}
+