=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/session.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- src/usr.bin/ssh/session.c 2001/10/10 22:18:47 1.107 +++ src/usr.bin/ssh/session.c 2001/10/11 13:45:21 1.108 @@ -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 @@ */ 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 @@ } 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 */