emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#19760: closed ([bug] "tail -f" with inotify fails


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#19760: closed ([bug] "tail -f" with inotify fails to follow a file after a rename())
Date: Tue, 31 Mar 2015 10:57:02 +0000

Your message dated Tue, 31 Mar 2015 11:56:40 +0100
with message-id <address@hidden>
and subject line Re: bug#19760: [bug] "tail -f" with inotify fails to follow a 
file after a rename()
has caused the debbugs.gnu.org bug report #19760,
regarding [bug] "tail -f" with inotify fails to follow a file after a rename()
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
19760: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19760
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [bug] "tail -f" with inotify fails to follow a file after a rename() Date: Tue, 3 Feb 2015 22:04:11 +0000 User-agent: Mutt/1.5.21 (2010-09-15)
Hello,

On Linux, when inotify is used,

   tail -f file

follows a file only until it's renamed. After it is renamed, the
inotify watch is removed, which means tail sits there doing
nothing and any further modifications to the file are ignored.

To reproduce:

    echo 1 > file
    tail -f file &
    exec 3>> file
    echo 2 >&3
    sleep 1
    mv file file2
    sleep 1
    echo 3 >&3
    sleep 1
    : > file2

"3" is not displayed. No message about the file being truncated
either.

Work arounds:

   tail ---disable-inotify -f file
   tail -f < file # effectively disables inotify

   or rename the file with a link() followed by an unlink()
   ln file newfile && rm -f file

Note that the IN_DELETED_SELF event is not reached in
follow-descriptor mode because tail has the file open preventing
it from being deleted even after it's unlinked from the last
directory.

Path attached (on the current git head).

I don't think IN_DELETED_SELF is useful in follow-name mode
either, but I've not removed it.

-- 
Stephane

Attachment: 0001-tail-fix-rename-in-follow-descriptor-mode.patch
Description: Text Data


--- End Message ---
--- Begin Message --- Subject: Re: bug#19760: [bug] "tail -f" with inotify fails to follow a file after a rename() Date: Tue, 31 Mar 2015 11:56:40 +0100 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
On 31/03/15 07:30, Bernhard Voelker wrote:
> On 03/31/2015 05:15 AM, Pádraig Brady wrote:
>> +  tail -f continues to follow changes to a file even after it's renamed.
>> +  [bug introduced in coreutils-7.5]
>> +
> 
> It is not 100% clear to me by this sentence what was the actual change;
> maybe a little "again" or "now" would help?
> 
>> --- /dev/null
>> +++ b/tests/tail-2/f-vs-rename.sh
>> @@ -0,0 +1,51 @@
>> +#!/bin/sh
>> +# demonstrate that tail -f works when renaming the tailed files
> 
> s/^d/D/; s/$/./
> 
>> +# Before coreutils-8.24, tail -f a would stop tracking additions to b
>> +# after "mv a b".
>> +
>> +# Copyright (C) 2015 Free Software Foundation, Inc.
>> +
>> +# This program is free software: you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation, either version 3 of the License, or
>> +# (at your option) any later version.
>> +
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +# GNU General Public License for more details.
>> +
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> +
>> +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
>> +print_ver_ tail
>> +
>> +touch a || framework_failure_
>> +
>> +debug='---disable-inotify'
>> +debug=
>> +tail $debug -f -s.1 a > out 2>&1 & pid=$!
> 
> Shouldn't $debug be removed?  Otherwise maybe a loop over both the
> inotify and the non-inotify mode would make sense?
> 
>> +
>> +check_tail_output()
>> +{
>> +  local delay="$1"
>> +  grep "$tail_re" out > /dev/null ||
>> +    { sleep $delay; return 1; }
>> +}
> 
> Please don't discard grep's output: reading the test's log file is
> easier with this included.
> 
>> +
>> +# Wait up to 12.7s for tail to start
> 
> s/$/./
> 
>> +echo x > a
>> +tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1
>> +
>> +mv a b || fail=1
>> +
>> +echo y >> b
>> +# Wait up to 12.7s for "y" to appear in the output:
>> +tail_re='^y$' retry_delay_ check_tail_output .1 7 || fail=1
>> +
>> +kill $pid
>> +
>> +wait
>> +
>> +Exit $fail
> 
> Otherwise +1 (including the changes in tail.c).

All good suggestions.
Latest attached.

thanks for the review!
Pádraig.

Attachment: tail-rename-desc.patch
Description: Text Data


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]