From 0585d51a52350409f63b687a02619a7617643309 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Fri, 12 Oct 2001 11:35:50 +1000 Subject: - markus@cvs.openbsd.org 2001/10/11 13:45:21 [session.c] 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. --- session.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'session.c') diff --git a/session.c b/session.c index 6ba2e7c77..e9d8ceb73 100644 --- a/session.c +++ b/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" @@ -1865,6 +1865,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 @@ -1963,8 +1966,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 */ -- cgit v1.2.3