diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-10-11 13:45:22 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-10-11 13:45:22 +0000 |
commit | 6828645865c24cd95f76e5ff2a80cc99575c1666 (patch) | |
tree | 36d3ee412712d8c066ef49ad556af30d2251c5ce | |
parent | f5c033b80f6604d285126e89ee89f0559b17ba32 (diff) |
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.
-rw-r--r-- | usr.bin/ssh/session.c | 14 |
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 */ |