summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-09-07 08:37:08 +0200
committerJim Meyering <meyering@redhat.com>2009-09-07 09:01:14 +0200
commitcdfb703c5da31a798557722df516e0d01dac828a (patch)
tree3689a7d406bc1a640f4127a63c64b2846b765fc6 /src
parent15f26e296b4948edc6c7d33fc1caa6cb50999364 (diff)
downloadcoreutils-cdfb703c5da31a798557722df516e0d01dac828a.tar.xz
tail -f: handle "-"/stdin once again
* src/tail.c (main) [HAVE_INOTIFY]: When stdin (i.e., "-", or no args, but not /dev/stdin) is specified on the command line, don't use inotify. Reported by Bill Brelsford in <http://bugs.debian.org/545422>. * tests/tail-2/follow-stdin: New file. Test for this. * tests/Makefile.am (TESTS): Add the test. * NEWS (Bug fixes): Mention it. This bug was introduced in coreutils-7.5 via commit ae494d4b, 2009-06-02, "tail: use inotify if it is available".
Diffstat (limited to 'src')
-rw-r--r--src/tail.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tail.c b/src/tail.c
index e3b9529f8..c53df9e3f 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1982,7 +1982,19 @@ main (int argc, char **argv)
if (forever)
{
#if HAVE_INOTIFY
- if (!disable_inotify)
+ /* If the user specifies stdin via a command line argument of "-",
+ or implicitly by providing no arguments, we won't use inotify.
+ Technically, on systems with a working /dev/stdin, we *could*,
+ but would it be worth it? Verifying that it's a real device
+ and hooked up to stdin is not trivial, while reverting to
+ non-inotify-based tail_forever is easy and portable. */
+ bool stdin_cmdline_arg = false;
+
+ for (i = 0; i < n_files; i++)
+ if (STREQ (file[i], "-"))
+ stdin_cmdline_arg = true;
+
+ if (!disable_inotify && !stdin_cmdline_arg)
{
int wd = inotify_init ();
if (wd < 0)