summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2001-10-11 13:45:21 +0000
committermarkus <markus@openbsd.org>2001-10-11 13:45:21 +0000
commit64aaf876dbe812fb72ed87cf4ee08e1de9f14148 (patch)
treeb24924599d6952ca56329ad4634d6d5dd5c3155b /usr.bin/ssh
parentFix various bugs in the example configuration. Most entries are (diff)
downloadwireguard-openbsd-64aaf876dbe812fb72ed87cf4ee08e1de9f14148.tar.xz
wireguard-openbsd-64aaf876dbe812fb72ed87cf4ee08e1de9f14148.zip
delay detach of session if a channel gets closed but the child is still alive.
however, release pty, since the fd's to the child are already closed.
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/session.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c
index b1d49314249..b9753dba16b 100644
--- a/usr.bin/ssh/session.c
+++ b/usr.bin/ssh/session.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.107 2001/10/10 22:18:47 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.108 2001/10/11 13:45:21 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -1487,6 +1487,9 @@ session_pty_cleanup(void *session)
*/
if (close(s->ptymaster) < 0)
error("close(s->ptymaster): %s", strerror(errno));
+
+ /* unlink pty from session */
+ s->ttyfd = -1;
}
static void
@@ -1581,8 +1584,15 @@ session_close_by_channel(int id, void *arg)
}
debug("session_close_by_channel: channel %d child %d", id, s->pid);
if (s->pid != 0) {
- /* delay detach */
debug("session_close_by_channel: channel %d: has child", id);
+ /*
+ * delay detach of session, but release pty, since
+ * the fd's to the child are already closed
+ */
+ if (s->ttyfd != -1) {
+ fatal_remove_cleanup(session_pty_cleanup, (void *)s);
+ session_pty_cleanup(s);
+ }
return;
}
/* detach by removing callback */