summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-09-24 22:02:56 +1000
committerDamien Miller <djm@mindrot.org>2010-09-24 22:02:56 +1000
commit857b02e37f3bd6d5390711521e2dd021beca3a3c (patch)
treeb6b488ccf04d9ffacaa4ce8caf80be9640ae30d5
parent881adf74eba06251604151cd4686fef3640b9008 (diff)
- djm@cvs.openbsd.org 2010/09/20 04:41:47
[ssh.c] install a SIGCHLD handler to reap expiried child process; ok markus@
-rw-r--r--ChangeLog3
-rw-r--r--ssh.c21
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f8596098d..f9e0f6c09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,9 @@
12 - jmc@cvs.openbsd.org 2010/09/19 21:30:05 12 - jmc@cvs.openbsd.org 2010/09/19 21:30:05
13 [sftp.1] 13 [sftp.1]
14 more wacky macro fixing; 14 more wacky macro fixing;
15 - djm@cvs.openbsd.org 2010/09/20 04:41:47
16 [ssh.c]
17 install a SIGCHLD handler to reap expiried child process; ok markus@
15 18
1620100910 1920100910
17 - (dtucker) [openbsd-compat/port-linux.c] Check is_selinux_enabled for exact 20 - (dtucker) [openbsd-compat/port-linux.c] Check is_selinux_enabled for exact
diff --git a/ssh.c b/ssh.c
index 70c71bc00..20de28a64 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.351 2010/09/02 16:08:39 markus Exp $ */ 1/* $OpenBSD: ssh.c,v 1.352 2010/09/20 04:41:47 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -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)
210static int ssh_session(void); 211static int ssh_session(void);
211static int ssh_session2(void); 212static int ssh_session2(void);
212static void load_public_identity_files(void); 213static void load_public_identity_files(void);
214static void main_sigchld_handler(int);
213 215
214/* from muxclient.c */ 216/* from muxclient.c */
215void muxclient(const char *); 217void muxclient(const char *);
@@ -877,6 +879,7 @@ main(int ac, char **av)
877 tilde_expand_filename(options.user_hostfile2, original_real_uid); 879 tilde_expand_filename(options.user_hostfile2, original_real_uid);
878 880
879 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ 881 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */
882 signal(SIGCHLD, main_sigchld_handler);
880 883
881 /* Log into the remote system. Never returns if the login fails. */ 884 /* Log into the remote system. Never returns if the login fails. */
882 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, 885 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr,
@@ -1545,3 +1548,19 @@ load_public_identity_files(void)
1545 bzero(pwdir, strlen(pwdir)); 1548 bzero(pwdir, strlen(pwdir));
1546 xfree(pwdir); 1549 xfree(pwdir);
1547} 1550}
1551
1552static void
1553main_sigchld_handler(int sig)
1554{
1555 int save_errno = errno;
1556 pid_t pid;
1557 int status;
1558
1559 while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
1560 (pid < 0 && errno == EINTR))
1561 ;
1562
1563 signal(sig, main_sigchld_handler);
1564 errno = save_errno;
1565}
1566