On 03/01/19 23:01, Ayappan P2 wrote: > > The problem happens only when we pipe the output of "tail -f" . > > I am not sure how one can take the truss of "/tail -f test_file | grep > 123" . > > I did little debugging on the tail code. This function "check_output_alive" > introduced by the commit (mentioned earlier in the thread) sents SIGPIPE > after doing a select () call in AIX. > And that makes it exit immediately. > > fd_set rfd; > FD_ZERO (&rfd); > FD_SET (STDOUT_FILENO, &rfd); > > /* readable event on STDOUT is equivalent to POLLERR, > and implies an error condition on output like broken pipe. */ > if (select (STDOUT_FILENO + 1, &rfd, NULL, NULL, &delay) == 1) > raise (SIGPIPE); > } > > I didn't understand the real reason behind this commit. > > Thanks > Ayappan P > > > > From: Bernhard Voelker <m...@bernhard-voelker.de> > To: Ayappan P2 <ayapp...@in.ibm.com>, 33...@debbugs.gnu.org > Date: 01/03/2019 11:53 PM > Subject: bug#33946: tail -f stops abruptly in AIX when piped. > Sent by: "Bug-coreutils" <bug-coreutils-bounces > +ayappap2=in.ibm....@gnu.org> > > > > On 1/3/19 6:39 PM, Ayappan P2 wrote: >>> On 01-Jan-2019, at 10:36 PM, Ayappan P2 <ayapp...@in.ibm.com> wrote: >>> Hi, >>> >>> I am running coreutils 8.30 in AIX machine and it seems like "tail -f" > is >>> not working as it used to be when the output is piped. >>> >>> # ./tail -f test_file | grep 123 >>> >>> (1) root @ aixoss-automation-3: 6.1.0.0: / >>> >>> It stops immediately and it seems like this commit >>> >>> > https://github.com/coreutils/coreutils/commit/ce0415fda108b7ec35181118fd7a2c9ee70331ee > >>> >>> has introduce this behavior. >>> >>> I checked in Linux with coreutils 8.30 where it works as like earlier >>> versions. >>> >>> Thanks >>> Ayappan P > >> Anyone has any idea on this issue ? >> >> Thanks >> Ayappan P > > Thanks for reporting. > It's hard (at least for me) to get hold on to an AIX system, > so would you post a trace file (from 'truss'), please? > > Second, is this specific to a certain AIX version? > > BTW: our tests should have caught this before the release. > Do you also get an error during 'make check'?
Our tests were incorrect :/ Note the need for this extra check was discussed at: https://lists.gnu.org/archive/html/coreutils/2017-06/msg00010.html Note the initial implementation there was with poll() rather than select(). That may work better on AIX. Could you try the poll() solution at the above link, on your system? Attached is a fixup for the test and an avoidance of the issue on AIX. cheers, Pádraig.
From 69f4b0db2af91b2b67608ae5205d54b7fff2a53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com> Date: Fri, 4 Jan 2019 09:29:13 -0800 Subject: [PATCH] tail: don't exit immediately with filters on AIX * src/tail.c: Avoid the check_output_available check on AIX. * 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. Addresses http://bugs.gnu.org/33946 --- NEWS | 8 +++++--- src/tail.c | 5 +++++ tests/tail-2/pipe-f.sh | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4a57d22..6a9c0bc 100644 --- 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 diff --git a/src/tail.c b/src/tail.c index 0270cbe..85de88d 100644 --- a/src/tail.c +++ b/src/tail.c @@ -336,6 +336,11 @@ named file in a way that accommodates renaming, removal and creation.\n\ static void check_output_alive (void) { +#ifdef _AIX + /* TODO: AIX was seen to give a readable event immediately. */ + return; +#endif + if (! monitor_output) return; diff --git a/tests/tail-2/pipe-f.sh b/tests/tail-2/pipe-f.sh index 9231cac..4a5b444 100755 --- a/tests/tail-2/pipe-f.sh +++ b/tests/tail-2/pipe-f.sh @@ -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 -- 2.9.3