]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor: output immediately if stdout is a tty but stdin is not
authorShugo Maeda <shugo@ruby-lang.org>
Sun, 31 Mar 2019 22:43:58 +0000 (15:43 -0700)
committerPádraig Brady <P@draigBrady.com>
Sun, 31 Mar 2019 22:49:48 +0000 (15:49 -0700)
* 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
src/factor.c

diff --git a/NEWS b/NEWS
index 459d10c98c6a4836145c36eadd2c543c3d2a6676..6844228bef9f8f2073a2c28b80269a18db25ed21 100644 (file)
--- 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).
index 39e8918ffe7285f9506b1a81c1d946e18864fdfd..1d6e566b441b682838d8b6cdd35e66e40e049ea9 100644 (file)
@@ -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)