changeset 93:5dda5a4d475c

Don't leave the stdin FD non-blocking on exit - busybox doesn't like it.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 18 Aug 2004 12:42:21 +0000
parents 2e92778dd162
children c85c88500ea6
files cli-chansession.c session.h
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cli-chansession.c	Wed Aug 18 09:14:43 2004 +0000
+++ b/cli-chansession.c	Wed Aug 18 12:42:21 2004 +0000
@@ -63,6 +63,10 @@
 
 	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, 
@@ -313,6 +317,11 @@
 
 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->errfd = STDERR_FILENO;
--- a/session.h	Wed Aug 18 09:14:43 2004 +0000
+++ b/session.h	Wed Aug 18 12:42:21 2004 +0000
@@ -212,6 +212,8 @@
 
 	int tty_raw_mode; /* Whether we're in raw mode (and have to clean up) */
 	struct termios saved_tio;
+	int stdincopy;
+	int stdinflags;
 
 	int winchange; /* Set to 1 when a windowchange signal happens */