GNU bug report logs - #27368
Minor concern: Confusing tail warning

Previous Next

Package: coreutils;

Reported by: Charlie Hagedorn <charlie.hagedorn <at> gmail.com>

Date: Wed, 14 Jun 2017 23:04:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Charlie Hagedorn <charlie.hagedorn <at> gmail.com>
Subject: bug#27368: closed (Re: bug#27368: Minor concern: Confusing tail
 warning)
Date: Sat, 17 Jun 2017 08:33:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#27368: Minor concern: Confusing tail warning

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 27368 <at> debbugs.gnu.org.

-- 
27368: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27368
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Pádraig Brady <P <at> draigBrady.com>
To: Charlie Hagedorn <charlie.hagedorn <at> gmail.com>, 27368-done <at> debbugs.gnu.org
Subject: Re: bug#27368: Minor concern: Confusing tail warning
Date: Sat, 17 Jun 2017 01:32:34 -0700
[Message part 3 (text/plain, inline)]
On 15/06/17 02:40, Pádraig Brady wrote:
> On 14/06/17 16:03, Charlie Hagedorn wrote:
>> Hi!
>>
>> Thank you for maintaining such useful and reliable tools.
>>
>> Today I came across an unexpected warning in tail. The warning is intended
>> to handle this case:
>>
>> [:~]$ tail -f
>> tail: warning: following standard input indefinitely is ineffective
>>
>> which is both important and fun.
>>
>> Today, however, I was surprised to see it appear in this context:
>>
>> [:~]$ tail -f < /dev/ttyUSB0  > data.dat
>> tail: warning: following standard input indefinitely is ineffective
>>
>> The warning was confusing and perhaps inappropriate, as this call actually
>> *does* something, and is very effective at doing what I want; streaming the
>> port's output into data.dat.
> 
> Right. The above command will go into non inotify blocking mode
> and will thus work as you expect.  Note tail will not output
> anything until the first time read() returns nothing.
> The following patch should suppress the warning if we would be using this mode.
> 
> diff --git a/src/tail.c b/src/tail.c
> index 3918373..2f9b981 100644
> --- a/src/tail.c
> +++ b/src/tail.c
> @@ -2365,12 +2365,22 @@ main (int argc, char **argv)
>      if (found_hyphen && follow_mode == Follow_name)
>        die (EXIT_FAILURE, 0, _("cannot follow %s by name"), quoteaf ("-"));
> 
> -    /* When following forever, warn if any file is '-'.
> +    /* When following forever, and not using simple blocking, warn if
> +       any file is '-' as the stats() used to check for input are ineffective.
>         This is only a warning, since tail's output (before a failing seek,
>         and that from any non-stdin files) might still be useful.  */
> -    if (forever && found_hyphen && isatty (STDIN_FILENO))
> -      error (0, 0, _("warning: following standard input"
> -                     " indefinitely is ineffective"));
> +    if (forever && found_hyphen)
> +      {
> +        struct stat in_stat;
> +        bool blocking_stdin;
> +        blocking_stdin = (pid == 0 && follow_mode == Follow_descriptor
> +                          && n_files == 1 && ! fstat (STDIN_FILENO, &in_stat)
> +                          && ! S_ISREG (in_stat.st_mode));
> +
> +        if (! blocking_stdin && isatty (STDIN_FILENO))
> +          error (0, 0, _("warning: following standard input"
> +                         " indefinitely is ineffective"));
> +      }
>    }
> 
>> (Importantly, for reasons I don't yet understand, tail -f /dev/ttyUSB0 >
>> data.dat does not reliably tail the port; it redirects only one line of
>> output instead of a continuous stream).
> 
> That looks like another case where we should be disabling inotify.
> I.E. you can see this waits forever for inotify events if you hit ctrl-d a few times:
> 
>   strace tail -f /dev/tty
> 
> Ah yes that was discussed at http://bugs.gnu.org/21265
> I suppose we should improve things here with a couple of patches.
> 
> 1. Disable inotify if any non regular files (except fifo/pipe)
> (the kernel should really disallow this, but best handle I think)
> 
> 2. Generalise the warning in the above patch to be:
> if (n_files > 1 && any_device_or_tty)
>   printf ("warning: following a stdin/device in combination with other inputs is ineffective")

Two proposed patches for this are attached.

cheers,
Pádraig.

[tail-pipe.diff (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Charlie Hagedorn <charlie.hagedorn <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Minor concern: Confusing tail warning
Date: Wed, 14 Jun 2017 16:03:07 -0700
[Message part 6 (text/plain, inline)]
Hi!

Thank you for maintaining such useful and reliable tools.

Today I came across an unexpected warning in tail. The warning is intended
to handle this case:

[:~]$ tail -f
tail: warning: following standard input indefinitely is ineffective

which is both important and fun.

Today, however, I was surprised to see it appear in this context:

[:~]$ tail -f < /dev/ttyUSB0  > data.dat
tail: warning: following standard input indefinitely is ineffective

The warning was confusing and perhaps inappropriate, as this call actually
*does* something, and is very effective at doing what I want; streaming the
port's output into data.dat.

(Importantly, for reasons I don't yet understand, tail -f /dev/ttyUSB0 >
data.dat does not reliably tail the port; it redirects only one line of
output instead of a continuous stream).

System is Debian Jessie -- coreutils v8.23-4.

Thanks!

Charlie
[Message part 7 (text/html, inline)]

This bug report was last modified 8 years and 53 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.