From 22ee6226ce3f2506844fad50f394eacca305b02e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Jan 2013 11:37:00 +0530 Subject: [PATCH] Workaround for broken C libraries causing stdout redirection for broken libmtp causing stdout to become fully buffered --- src/calibre/devices/mtp/unix/libmtp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/calibre/devices/mtp/unix/libmtp.c b/src/calibre/devices/mtp/unix/libmtp.c index 920ddde3d1..5a274b2e89 100644 --- a/src/calibre/devices/mtp/unix/libmtp.c +++ b/src/calibre/devices/mtp/unix/libmtp.c @@ -734,6 +734,7 @@ initlibmtp(void) { // who designs a library without anyway to control/redirect the debugging // output, and hardcoded paths that cannot be changed? int bak, new; + fprintf(stdout, "\n"); // This is needed, without it, for some odd reason the code below causes stdout to buffer all output after it is restored, rather than using line buffering, and setlinebuf does not work. fflush(stdout); bak = dup(STDOUT_FILENO); new = open("/dev/null", O_WRONLY);