Description: Install a SIGCHLD handler to reap expired child processes Origin: upstream, http://bazaar.launchpad.net/~vcs-imports/openssh/main/revision/6166 Bug-Debian: http://bugs.debian.org/594687 Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1812 Forwarded: not-needed Last-Update: 2010-10-26 Index: b/ssh.c =================================================================== --- a/ssh.c +++ b/ssh.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -210,6 +211,7 @@ static int ssh_session(void); static int ssh_session2(void); static void load_public_identity_files(void); +static void main_sigchld_handler(int); /* from muxclient.c */ void muxclient(const char *); @@ -849,6 +851,7 @@ tilde_expand_filename(options.user_hostfile2, original_real_uid); signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ + signal(SIGCHLD, main_sigchld_handler); /* Log into the remote system. Never returns if the login fails. */ ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, @@ -1532,3 +1535,19 @@ bzero(pwdir, strlen(pwdir)); xfree(pwdir); } + +static void +main_sigchld_handler(int sig) +{ + int save_errno = errno; + pid_t pid; + int status; + + while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || + (pid < 0 && errno == EINTR)) + ; + + signal(sig, main_sigchld_handler); + errno = save_errno; +} +