--- sshd.c.in Sun Apr 21 20:49:32 2002 +++ sshd.c Wed Apr 24 22:36:06 2002 @@ -265,10 +265,14 @@ { int save_errno = errno; int status; + pid_t pid; - while (waitpid(-1, &status, WNOHANG) > 0) - ; - + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { +#ifdef HAVE_CYGWIN + if (msbug_close(pid, -1)) + error("msbug_close %s", strerror(errno)); +#endif + } signal(SIGCHLD, main_sigchld_handler); errno = save_errno; } @@ -888,11 +892,17 @@ verbose("socket: %.100s", strerror(errno)); continue; } +#ifndef HAVE_CYGWIN if (fcntl(listen_sock, F_SETFL, O_NONBLOCK) < 0) { error("listen_sock O_NONBLOCK: %s", strerror(errno)); close(listen_sock); continue; } +#else /* Don't dup listen_sock in forked processes */ + if (fcntl(listen_sock, F_SETCF, 0) < 0) { + error("listen_sock F_SETCF: %s", strerror(errno)); + } +#endif /* * Set socket options. We try to make the port * reusable and have it close as fast as possible @@ -1091,7 +1101,11 @@ */ startup_pipe = startup_p[1]; close_startup_pipes(); +#ifndef HAVE_CYGWIN close_listen_socks(); +#else /* Not opened in CYGWIN */ + num_listen_socks = -1; +#endif sock_in = newsock; sock_out = newsock; log_init(__progname, options.log_level, options.log_facility, log_stderr); @@ -1117,9 +1131,14 @@ } arc4random_stir(); - +#ifndef HAVE_CYGWIN /* Close the new socket (the child is now taking care of it). */ close(newsock); +#else + if (msbug_close(pid, newsock)) + error("msbug_close %s", strerror(errno)); +#endif + } /* child process check (or debug mode) */ if (num_listen_socks < 0) @@ -1519,3 +1538,4 @@ #endif debug("KEX done"); } +