Mercurial > dropbear
changeset 938:c88dce72f6d2
Make sure client exit messages don't get lost
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 09 Jul 2014 00:13:17 +0800 |
parents | 4ad38e223ccd |
children | a0819ecfee0b |
files | cli-main.c common-channel.c |
diffstat | 2 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/cli-main.c Tue Jul 08 21:59:36 2014 +0800 +++ b/cli-main.c Wed Jul 09 00:13:17 2014 +0800 @@ -107,9 +107,10 @@ /* 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 @@ 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) {
--- a/common-channel.c Tue Jul 08 21:59:36 2014 +0800 +++ b/common-channel.c Wed Jul 09 00:13:17 2014 +0800 @@ -574,14 +574,16 @@ } - /* 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) {