Workaround for broken C libraries causing stdout redirection for broken libmtp causing stdout to become fully buffered

This commit is contained in:
Kovid Goyal 2013-01-04 11:37:00 +05:30
parent 65d51e3050
commit 22ee6226ce

View File

@ -734,6 +734,7 @@ initlibmtp(void) {
// who designs a library without anyway to control/redirect the debugging // who designs a library without anyway to control/redirect the debugging
// output, and hardcoded paths that cannot be changed? // output, and hardcoded paths that cannot be changed?
int bak, new; 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); fflush(stdout);
bak = dup(STDOUT_FILENO); bak = dup(STDOUT_FILENO);
new = open("/dev/null", O_WRONLY); new = open("/dev/null", O_WRONLY);