[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19760: [bug] "tail -f" with inotify fails to follow a file after a r
From: |
Stephane Chazelas |
Subject: |
bug#19760: [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
0001-tail-fix-rename-in-follow-descriptor-mode.patch
Description: Text Data
- bug#19760: [bug] "tail -f" with inotify fails to follow a file after a rename(),
Stephane Chazelas <=