From 6d78a28078feb6bfd26c6f1cc0ddbb0a356514c4 Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Sun, 31 Mar 2019 15:43:58 -0700 Subject: [PATCH] factor: output immediately if stdout is a tty but stdin is not * src/factor.c (lbuf_putc): Use line buffered mode if the standard output is a terminal in the same way as the stdio library. User programs might use pty only for the standard out like the example of Ruby's PTY module: https://docs.ruby-lang.org/en/2.6.0/PTY.html#module-PTY-label-Example * NEWS: Mention the fix. Fixes https://bugs.gnu.orv/35046 --- NEWS | 3 +++ src/factor.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 459d10c98c..6844228bef 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*- ** Bug fixes + factor again outputs immediately when stdout is a tty but stdin is not. + [bug introduced in coreutils-8.24] + ln works again on old systems without O_DIRECTORY support (like Solaris 10), and on systems where symlink ("x", ".") fails with errno == EINVAL (like Solaris 10 and Solaris 11). diff --git a/src/factor.c b/src/factor.c index 39e8918ffe..1d6e566b44 100644 --- a/src/factor.c +++ b/src/factor.c @@ -2400,10 +2400,10 @@ lbuf_putc (char c) { size_t buffered = lbuf.end - lbuf.buf; - /* Provide immediate output for interactive input. */ + /* Provide immediate output for interactive use. */ static int line_buffered = -1; if (line_buffered == -1) - line_buffered = isatty (STDIN_FILENO); + line_buffered = isatty (STDIN_FILENO) || isatty (STDOUT_FILENO); if (line_buffered) lbuf_flush (); else if (buffered >= FACTOR_PIPE_BUF) -- 2.47.2