[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.
This commit is contained in:
Damien Miller 2001-10-12 11:35:50 +10:00
parent 3ec2759ad4
commit 0585d51a52
2 changed files with 18 additions and 3 deletions

View File

@ -7,6 +7,11 @@
don't kill the login shells if the shells stdin/out/err is closed. don't kill the login shells if the shells stdin/out/err is closed.
this should now work: this should now work:
ssh -2n localhost 'exec > /dev/null 2>&1; sleep 10; exit 5'; echo ? ssh -2n localhost 'exec > /dev/null 2>&1; sleep 10; exit 5'; echo ?
- 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.
20011010 20011010
- (djm) OpenBSD CVS Sync - (djm) OpenBSD CVS Sync
@ -6705,4 +6710,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1601 2001/10/12 01:35:04 djm Exp $ $Id: ChangeLog,v 1.1602 2001/10/12 01:35:50 djm Exp $

View File

@ -33,7 +33,7 @@
*/ */
#include "includes.h" #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 "ssh.h"
#include "ssh1.h" #include "ssh1.h"
@ -1865,6 +1865,9 @@ session_pty_cleanup(void *session)
*/ */
if (close(s->ptymaster) < 0) if (close(s->ptymaster) < 0)
error("close(s->ptymaster): %s", strerror(errno)); error("close(s->ptymaster): %s", strerror(errno));
/* unlink pty from session */
s->ttyfd = -1;
} }
static void 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); debug("session_close_by_channel: channel %d child %d", id, s->pid);
if (s->pid != 0) { if (s->pid != 0) {
/* delay detach */
debug("session_close_by_channel: channel %d: has child", id); 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; return;
} }
/* detach by removing callback */ /* detach by removing callback */