grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.27-29-g7ad47ab


From: Paul Eggert
Subject: grep branch, master, updated. v2.27-29-g7ad47ab
Date: Tue, 27 Dec 2016 19:19:31 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  7ad47abbcb070946000771a829b51224720b8cef (commit)
      from  1a45e78b8759073c6f184039324d5b4bf8ef8f95 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=7ad47abbcb070946000771a829b51224720b8cef


commit 7ad47abbcb070946000771a829b51224720b8cef
Author: Paul Eggert <address@hidden>
Date:   Tue Dec 27 11:16:32 2016 -0800

    grep: fix bug with '... | grep pat >> /dev/null'
    
    Problem reported by Benno Fünfstück (Bug#25283).
    * NEWS: Document this.
    * src/grep.c (drain_input) [SPLICE_F_MOVE]:
    Don't assume /dev/null is always acceptable output to splice.
    * tests/grep-dev-null-out: Test for the bug.

diff --git a/NEWS b/NEWS
index 2e7d1ae..8830582 100644
--- a/NEWS
+++ b/NEWS
@@ -4,9 +4,10 @@ GNU grep NEWS                                    -*- outline 
-*-
 
 ** Bug fixes
 
-  grep no longer fails when standard input is a file in the Linux
-  /proc file system and standard output is /dev/null.
-  [bug introduced in grep-2.27]
+  When standard output is /dev/null, grep no longer fails when
+  standard input is a file in the Linux /proc file system, or when
+  standard input is a pipe and standard output is in append mdoe.
+  [bugs introduced in grep-2.27]
 
 ** Bug fixes
 
diff --git a/src/grep.c b/src/grep.c
index f28f3c2..aebab20 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1728,11 +1728,15 @@ drain_input (int fd, struct stat const *st)
     {
 #ifdef SPLICE_F_MOVE
       /* Should be faster, since it need not copy data to user space.  */
-      while ((nbytes = splice (fd, NULL, STDOUT_FILENO, NULL,
-                               INITIAL_BUFSIZE, SPLICE_F_MOVE)))
-        if (nbytes < 0)
-          return false;
-      return true;
+      nbytes = splice (fd, NULL, STDOUT_FILENO, NULL,
+                       INITIAL_BUFSIZE, SPLICE_F_MOVE);
+      if (0 <= nbytes || errno != EINVAL)
+        {
+          while (0 < nbytes)
+            nbytes = splice (fd, NULL, STDOUT_FILENO, NULL,
+                             INITIAL_BUFSIZE, SPLICE_F_MOVE);
+          return nbytes == 0;
+        }
 #endif
     }
   while ((nbytes = safe_read (fd, buffer, bufalloc)))
diff --git a/tests/grep-dev-null-out b/tests/grep-dev-null-out
index 13a4843..c8128d5 100755
--- a/tests/grep-dev-null-out
+++ b/tests/grep-dev-null-out
@@ -8,4 +8,6 @@ require_timeout_
 ${AWK-awk} 'BEGIN {while (1) print "x"}' </dev/null |
   returns_ 124 timeout 1 grep x >/dev/null || fail=1
 
+echo abc | grep b >>/dev/null || fail=1
+
 Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 NEWS                    |    7 ++++---
 src/grep.c              |   14 +++++++++-----
 tests/grep-dev-null-out |    2 ++
 3 files changed, 15 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]