]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: don't exit immediately with filters on AIX
authorPádraig Brady <P@draigBrady.com>
Fri, 4 Jan 2019 17:29:13 +0000 (09:29 -0800)
committerPádraig Brady <P@draigBrady.com>
Sun, 13 Jan 2019 03:23:41 +0000 (19:23 -0800)
* src/tail.c: Fix the check_output_available check on AIX.
Note we don't use poll for all systems as the overhead
of adding the gnulib poll module wouldn't be worth it
just for this single use.
* tests/tail-2/pipe-f.sh: Fix the test which always passed
due to only the exit code of sleep being checked.
* NEWS: Mention the bug fix and rearrange alphabetically.
Fixes http://bugs.gnu.org/33946

NEWS
src/tail.c
tests/tail-2/pipe-f.sh

diff --git a/NEWS b/NEWS
index 4a57d221b48d4e6089eb71a4dc3fd32371beb470..6a9c0bca2fb51532329b6796758b0fc84d98e010 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  'base64 a b' now correctly diagnoses 'b' as the extra operand, not 'a'.
+  [bug introduced in coreutils-5.3.0]
+
   When B already exists, 'cp -il A B' no longer immediately fails
   after asking the user whether to proceed.
   [This bug was present in "the beginning".]
@@ -21,9 +24,8 @@ GNU coreutils NEWS                                    -*- outline -*-
   sync no longer fails for write-only file arguments.
   [bug introduced with argument support to sync in coreutils-8.24]
 
-  In 'base64 a b', and likewise for base32, the tool now correctly
-  diagnoses 'b' as the extra operand, not 'a'.
-  [bug introduced in coreutils-5.3.0]
+  'tail -f file | filter' no longer exits immediately on AIX.
+  [bug introduced in coreutils-8.28]
 
 ** Changes in behavior
 
index 0270cbe07724eaf0c1d176650e7b4f735bdd09ef..9f5f44315a73386fc20eaec29789ddf7293d8fd6 100644 (file)
@@ -30,6 +30,9 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include <signal.h>
+#ifdef _AIX
+# include <poll.h>
+#endif
 
 #include "system.h"
 #include "argmatch.h"
@@ -336,6 +339,16 @@ named file in a way that accommodates renaming, removal and creation.\n\
 static void
 check_output_alive (void)
 {
+#ifdef _AIX
+  /* select on AIX was seen to give a readable event immediately.  */
+  struct pollfd pfd;
+  pfd.fd = STDOUT_FILENO;
+  pfd.events = POLLERR;
+
+  if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & POLLERR))
+    raise (SIGPIPE);
+#endif
+
   if (! monitor_output)
     return;
 
index 9231cac4b08f939c11060ba9a56eb674ca143345..4a5b444f364c1c7e894c6c4d9363f3322ac3cace 100755 (executable)
@@ -37,7 +37,10 @@ compare exp out || fail=1
 
 # This would wait indefinitely before v8.28 due to no EPIPE being
 # generated due to no data written after the first small amount
-timeout 10 tail -f $mode $fastpoll out | sleep .1 || fail=1
+(returns_ 124 timeout 10 tail -n2 -f $mode $fastpoll out && touch timed_out) |
+ sed 2q > out2
+test -e timed_out && fail=1
+compare exp out2 || fail=1
 
 # This would wait indefinitely before v8.28 (until first write)
 (returns_ 1 timeout 10 tail -f $mode $fastpoll /dev/null >&-) || fail=1