If stdout is not a tty, we don't need immediate feedback, and not buffering it can cause a significant slow down in case the amount printed each time is very small. Reported-by: Shawn Landden <shawnlandden@gmail.com>
@@ -40,6 +40,8 @@ dpkg (1.17.2) UNRELEASED; urgency=low
* Fix «dpkg-query --list» output when using multibyte character strings,
to avoid unaligned columns and mojibake. Closes: #257505, #718541
Based on a patch by Changwoo Ryu <cwryu@debian.org>.
+ * Use fully buffered output on non-tty stdout.
+ Reported by Shawn Landden <shawnlandden@gmail.com>.
[ Updated programs translations ]
* German (Sven Joachim).
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <stdio.h>
+#include <unistd.h>
#include <dpkg/macros.h>
#include <dpkg/i18n.h>
@@ -33,7 +34,10 @@
void
dpkg_set_report_buffer(FILE *fp)
{
- setvbuf(fp, NULL, _IONBF, 0);
+ if (isatty(STDOUT_FILENO))
+ setvbuf(fp, NULL, _IONBF, 0);
+ else
+ setvbuf(fp, NULL, _IOFBF, 0);
}
static int warn_count = 0;