diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2010-09-20 04:41:48 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2010-09-20 04:41:48 +0000 |
commit | bd72fd2a6d609957ee9b1a04c159fc3827c137ff (patch) | |
tree | f3d8fe7aca4d35033760bd4acba9ad3ffdcc1d12 | |
parent | fade4b49a0c128287af5cafa0a3bda108e3464c3 (diff) |
install a SIGCHLD handler to reap expiried child process; ok markus@
-rw-r--r-- | usr.bin/ssh/ssh.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index f141be63642..071c7136d21 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.351 2010/09/02 16:08:39 markus Exp $ */ +/* $OpenBSD: ssh.c,v 1.352 2010/09/20 04:41:47 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -49,6 +49,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> +#include <sys/wait.h> #include <ctype.h> #include <errno.h> @@ -202,6 +203,7 @@ usage(void) 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 *); @@ -839,6 +841,7 @@ main(int ac, char **av) 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, @@ -1507,3 +1510,19 @@ load_public_identity_files(void) 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; +} + |