summaryrefslogtreecommitdiffhomepage
path: root/cli-session.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli-session.c')
-rw-r--r--cli-session.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/cli-session.c b/cli-session.c
index 258d5c4..42770f5 100644
--- a/cli-session.c
+++ b/cli-session.c
@@ -9,10 +9,13 @@
#include "channel.h"
#include "random.h"
#include "service.h"
+#include "runopts.h"
+#include "chansession.h"
static void cli_remoteclosed();
static void cli_sessionloop();
static void cli_session_init();
+static void cli_finished();
struct clientsession cli_ses; /* GLOBAL */
@@ -163,6 +166,12 @@ static void cli_sessionloop() {
cli_ses.state = SESSION_RUNNING;
return;
+ case SESSION_RUNNING:
+ if (ses.chancount < 1) {
+ cli_finished();
+ }
+ return;
+
/* XXX more here needed */
@@ -174,6 +183,26 @@ static void cli_sessionloop() {
}
+void cli_session_cleanup() {
+
+ if (!sessinitdone) {
+ return;
+ }
+ cli_tty_cleanup();
+
+}
+
+static void cli_finished() {
+
+ cli_session_cleanup();
+ common_session_cleanup();
+ fprintf(stderr, "Connection to %s@%s:%s closed.\n", cli_opts.username,
+ cli_opts.remotehost, cli_opts.remoteport);
+ exit(EXIT_SUCCESS);
+}
+
+
+
/* called when the remote side closes the connection */
static void cli_remoteclosed() {