diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -50,6 +50,7 @@ | |||
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/param.h> | 51 | #include <sys/param.h> |
52 | #include <sys/socket.h> | 52 | #include <sys/socket.h> |
53 | #include <sys/wait.h> | ||
53 | 54 | ||
54 | #include <ctype.h> | 55 | #include <ctype.h> |
55 | #include <errno.h> | 56 | #include <errno.h> |
@@ -210,6 +211,7 @@ usage(void) | |||
210 | static int ssh_session(void); | 211 | static int ssh_session(void); |
211 | static int ssh_session2(void); | 212 | static int ssh_session2(void); |
212 | static void load_public_identity_files(void); | 213 | static void load_public_identity_files(void); |
214 | static void main_sigchld_handler(int); | ||
213 | 215 | ||
214 | /* from muxclient.c */ | 216 | /* from muxclient.c */ |
215 | void muxclient(const char *); | 217 | void muxclient(const char *); |
@@ -849,6 +851,7 @@ main(int ac, char **av) | |||
849 | tilde_expand_filename(options.user_hostfile2, original_real_uid); | 851 | tilde_expand_filename(options.user_hostfile2, original_real_uid); |
850 | 852 | ||
851 | signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ | 853 | signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ |
854 | signal(SIGCHLD, main_sigchld_handler); | ||
852 | 855 | ||
853 | /* Log into the remote system. Never returns if the login fails. */ | 856 | /* Log into the remote system. Never returns if the login fails. */ |
854 | ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, | 857 | ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, |
@@ -1532,3 +1535,19 @@ load_public_identity_files(void) | |||
1532 | bzero(pwdir, strlen(pwdir)); | 1535 | bzero(pwdir, strlen(pwdir)); |
1533 | xfree(pwdir); | 1536 | xfree(pwdir); |
1534 | } | 1537 | } |
1538 | |||
1539 | static void | ||
1540 | main_sigchld_handler(int sig) | ||
1541 | { | ||
1542 | int save_errno = errno; | ||
1543 | pid_t pid; | ||
1544 | int status; | ||
1545 | |||
1546 | while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || | ||
1547 | (pid < 0 && errno == EINTR)) | ||
1548 | ; | ||
1549 | |||
1550 | signal(sig, main_sigchld_handler); | ||
1551 | errno = save_errno; | ||
1552 | } | ||
1553 | |||