summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2014-07-09 00:13:17 +0800
committerMatt Johnston <matt@ucc.asn.au>2014-07-09 00:13:17 +0800
commit1ccac01cee0222be332b46d7102336465760aa11 (patch)
treeb569df842f267251bdaaf6d86db621ee953b8eaa
parent50a5d3756fedee5078b756a686cc24213dcfcb02 (diff)
Make sure client exit messages don't get lost
-rw-r--r--cli-main.c5
-rw-r--r--common-channel.c18
2 files changed, 13 insertions, 10 deletions
diff --git a/cli-main.c b/cli-main.c
index 3db8f2f..8c7f2ef 100644
--- a/cli-main.c
+++ b/cli-main.c
@@ -107,9 +107,10 @@ static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
/* Do the cleanup first, since then the terminal will be reset */
session_cleanup();
+ /* Avoid printing onwards from terminal cruft */
+ fprintf(stderr, "\n");
_dropbear_log(LOG_INFO, fmtbuf, param);
-
exit(exitcode);
}
@@ -121,7 +122,7 @@ static void cli_dropbear_log(int UNUSED(priority),
vsnprintf(printbuf, sizeof(printbuf), format, param);
fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf);
-
+ fflush(stderr);
}
static void exec_proxy_cmd(void *user_data_cmd) {
diff --git a/common-channel.c b/common-channel.c
index 634d823..61b1120 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -574,14 +574,16 @@ static void remove_channel(struct Channel * channel) {
}
- /* close the FDs in case they haven't been done
- * yet (they might have been shutdown etc) */
- TRACE(("CLOSE writefd %d", channel->writefd))
- close(channel->writefd);
- TRACE(("CLOSE readfd %d", channel->readfd))
- close(channel->readfd);
- TRACE(("CLOSE errfd %d", channel->errfd))
- close(channel->errfd);
+ if (IS_DROPBEAR_SERVER || (channel->writefd != STDOUT_FILENO)) {
+ /* close the FDs in case they haven't been done
+ * yet (they might have been shutdown etc) */
+ TRACE(("CLOSE writefd %d", channel->writefd))
+ close(channel->writefd);
+ TRACE(("CLOSE readfd %d", channel->readfd))
+ close(channel->readfd);
+ TRACE(("CLOSE errfd %d", channel->errfd))
+ close(channel->errfd);
+ }
if (!channel->close_handler_done
&& channel->type->closehandler) {