changeset 99:0247fbd9379d

Move the revert-to-non-blocking-stdin code to cli-session so it always gets hit.
author Matt Johnston <matt@ucc.asn.au>
date Sun, 22 Aug 2004 09:23:59 +0000
parents 297167ef41bd
children c72f5c10125d
files cli-chansession.c cli-session.c
diffstat 2 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/cli-chansession.c	Sun Aug 22 09:23:11 2004 +0000
+++ b/cli-chansession.c	Sun Aug 22 09:23:59 2004 +0000
@@ -63,10 +63,6 @@
 
 	cli_tty_cleanup(); /* Restore tty modes etc */
 
-	/* Set stdin back to non-blocking - busybox ash dies nastily
-	 * if we don't revert the flags */
-	fcntl(cli_ses.stdincopy, F_SETFL, cli_ses.stdinflags);
-
 }
 
 static void start_channel_request(struct Channel *channel, 
@@ -317,13 +313,9 @@
 
 static int cli_initchansess(struct Channel *channel) {
 
-	/* We store stdin's flags, so we can set them back on exit (otherwise
-	 * busybox's ash isn't happy */
-	cli_ses.stdincopy = dup(STDIN_FILENO);
-	cli_ses.stdinflags = fcntl(STDIN_FILENO, F_GETFL, 0);
 
 	channel->infd = STDOUT_FILENO;
-	//channel->outfd = STDIN_FILENO;
+	channel->outfd = STDIN_FILENO;
 	//channel->errfd = STDERR_FILENO;
 
 	if (cli_opts.wantpty) {
--- a/cli-session.c	Sun Aug 22 09:23:11 2004 +0000
+++ b/cli-session.c	Sun Aug 22 09:23:59 2004 +0000
@@ -112,6 +112,11 @@
 	cli_ses.tty_raw_mode = 0;
 	cli_ses.winchange = 0;
 
+	/* We store stdin's flags, so we can set them back on exit (otherwise
+	 * busybox's ash isn't happy */
+	cli_ses.stdincopy = dup(STDIN_FILENO);
+	cli_ses.stdinflags = fcntl(STDIN_FILENO, F_GETFL, 0);
+
 	/* Auth */
 	cli_ses.lastpubkey = NULL;
 	cli_ses.lastauthtype = NULL;
@@ -240,6 +245,12 @@
 	if (!sessinitdone) {
 		return;
 	}
+
+	/* Set stdin back to non-blocking - busybox ash dies nastily
+	 * if we don't revert the flags */
+	TRACE(("close stdincopy = %d", cli_ses.stdincopy));
+	//fcntl(cli_ses.stdincopy, F_SETFL, cli_ses.stdinflags);
+
 	cli_tty_cleanup();
 
 }