bug#21460: Race condition in tests/tail-2/assert.sh
From:
Ludovic Courtès
Subject:
bug#21460: Race condition in tests/tail-2/assert.sh
Date:
Fri, 11 Sep 2015 22:55:01 +0200
User-agent:
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Paul Eggert <address@hidden> skribis:
> Ludovic Courtès wrote:
>> I think the problem happens when ‘tail’ opens ‘foo’ right in between of
>> the two notifications: ‘foo’ is still there, and so ‘tail’ doesn’t
>> report anything.
>>
>> Does that make sense?
>
> Yes, though if the link count is indeed zero, I'm surprised that
> 'tail' can open the file -- that sounds like a bug in the kernel.
Attached is a reproducer; just run it in a loop for a couple of seconds:
--8<---------------cut here---------------start------------->8---
$ while ./a.out ; do : ; done
funny, errno = Success, nlink = 0
Aborted (core dumped)
--8<---------------cut here---------------end--------------->8---
I’m not sure if that’s a kernel bug. Strictly speaking, inotify works
as expected: we get a notification for nlink--, which doesn’t mean the
file has vanished.
The conclusion for ‘tail’ would be to wait for the IN_DELETE_SELF event
before considering the file to be gone. WDYT?
(That ‘inotify_rm_watch’ returns EINVAL *is* a bug IMO, but not
worrisome.)
Thanks,
Ludo’.