[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tail -f problem
From: |
Pádraig Brady |
Subject: |
Re: tail -f problem |
Date: |
Tue, 15 Sep 2009 10:18:04 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Jim Meyering wrote:
>
> diff --git a/src/tail.c b/src/tail.c
> @@ -1986,8 +1964,13 @@ main (int argc, char **argv)
> size_t n_viable = 0;
> for (i = 0; i < n_files; i++)
> {
> - if (STREQ (F[i].name, "-") && !F[i].ignore
> - && 0 <= F[i].fd && S_ISFIFO (F[i].mode))
> + bool is_a_fifo_or_pipe =
> + (STREQ (F[i].name, "-")
> + && !F[i].ignore
> + && 0 <= F[i].fd
> + && (S_ISFIFO (F[i].mode)
> + || (HAVE_FIFO_PIPES != 1 && isapipe (F[i].fd))));
> + if (is_a_fifo_or_pipe)
> F[i].ignore = true;
> else
> ++n_viable;
Note that old code you moved down has an issue under ksh
which causes tail-2/pipe-f to fail.
I.E. this will wait under ksh for both original and new tail:
echo foobar | POSIXLY_CORRECT="" tail -c3 -f
This seems to be because the HAVE_FIFO_PIPES compile time test,
which assumes the shell is going to call pipe().
BTW, tail is the only coreutils user of isapipe().
Could tail in this case just do:
S_ISFIFO (F[i].mode) || S_ISSOCK (F[i].mode)
I'm not sure about the general isapipe() case.
cheers,
Pádraig.