From 8dbb3fe7a90799590b6adf2acf77f7480afa0fb8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 22 Sep 2012 17:48:09 +0200 Subject: [PATCH] flush stdout more to make sure it is timely written and not interleaved with stderr even when when redirected. --- src/drv_imap.c | 6 +++++- src/socket.c | 4 +++- src/util.c | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index bb069f8..50a3eb2 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -250,6 +250,7 @@ send_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd ) printf( ">>> %s", buf ); else printf( ">>> %d LOGIN \n", cmd->tag ); + fflush( stdout ); } if (socket_write( &ctx->conn, buf, bufl, KeepOwn ) < 0) goto bail; @@ -573,6 +574,7 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts ) puts( "=========" ); fwrite( cur->val, cur->len, 1, stdout ); puts( "=========" ); + fflush( stdout ); } getline: @@ -1185,8 +1187,10 @@ do_cram_auth( imap_store_t *ctx, struct imap_cmd *cmdp, const char *prompt ) cram( prompt, srvc->user, srvc->pass, &resp, &l ); - if (DFlags & VERBOSE) + if (DFlags & VERBOSE) { printf( ">+> %s\n", resp ); + fflush( stdout ); + } return socket_write( &ctx->conn, resp, l, GiveOwn ); } #endif diff --git a/src/socket.c b/src/socket.c index 53d7545..e372483 100644 --- a/src/socket.c +++ b/src/socket.c @@ -539,8 +539,10 @@ socket_read_line( conn_t *b ) if (p != s && p[-1] == '\r') p--; *p = 0; - if (DFlags & VERBOSE) + if (DFlags & VERBOSE) { puts( s ); + fflush( stdout ); + } return s; } diff --git a/src/util.c b/src/util.c index 507f91a..ba05efa 100644 --- a/src/util.c +++ b/src/util.c @@ -37,6 +37,7 @@ flushn( void ) { if (need_nl) { putchar( '\n' ); + fflush( stdout ); need_nl = 0; } }