From: Shugo Maeda Date: Sun, 31 Mar 2019 22:43:58 +0000 (-0700) Subject: factor: output immediately if stdout is a tty but stdin is not X-Git-Tag: v8.32~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d78a28078feb6bfd26c6f1cc0ddbb0a356514c4;p=thirdparty%2Fcoreutils.git 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 --- 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)