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

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

bug#57536: 28.1; filenotify problems on macOS with symbolic links to dir


From: Michael Albinus
Subject: bug#57536: 28.1; filenotify problems on macOS with symbolic links to directories
Date: Sun, 04 Sep 2022 13:42:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

Hi,

>> Referencing these commands:
>> ; 1
>> (require 'filenotify)
>>
>> ; 2
>> (defun my-callback (directory)
>>   (message (format "called %s" directory)))
>>
>> ; 3
>> (file-notify-add-watch "/private/tmp"  '(change attribute-change) 
>> 'my-callback)
>>
>> ; 4
>> (file-notify-add-watch "/tmp"  '(change attribute-change) 'my-callback)
>>
>> Starting with a fresh emacs -Q, if I execute lines 1, 2, and 3 and then
>> touch a file such as /tmp/OUT, I get the notification as I should.
>>
>> However if I start fresh, execute lines 1, 2, and 4, and touch /tmp/OUT,
>> I do not get a notification.
>>
>> On a Mac, /tmp is a symbolic link to private/tmp (relative path).
>
> I don't see any bug here.  If file-notify-add-watch would resolve
> symlinks of its argument, we would be unable to watch changes to the
> symlink file itself.

I agree. Emacs' file notifications are not designed to follow
symlinks. The manual in (info "(elisp) File Notifications") is silent
about, perhaps we shall clarify.

> So if you want to watch changes for the target of a symlink, your Lisp
> program needs to resolve symlinks, e.g. by calling file-truename or
> something similar.

Yep.

>> I first discovered this issue using Helm's find-file and I entered a
>> report with Helm.  The Helm developer reports that it works in his case
>> with Linux.
>
> That could be a (mis)feature of our use of inotify, which is used on
> GNU/Linux for implementing file notifications.  AFAIU, inotify allows
> control on whether to follow symlinks when setting a watch, and its
> default is to follow symlinks.  I think we should call inotify so as
> not to follow symlinks.

Yep. We shall go through our f-n libraries and check the current
behavior, preferred by a new test case. And we shall adjust the
libraries to behave similar.

Will do next days.

Btw, there are bug#16113 and bug#18883, which report a similar problem
in auto-reverting. A possible solution could be to extend the FLAGS arg
of file-notify-add-watch by a condition 'follow', which means to
supervise the expanded symlink instead of the link file itself.

inotify knows the mask bit IN_DONT_FOLLOW (which we haven't set yet),
see inotify(7). Other libraries might offer similar possibilities, which
I haven't checked yet.

Best regards, Michael.





reply via email to

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