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: Eli Zaretskii
Subject: bug#57536: 28.1; filenotify problems on macOS with symbolic links to directories
Date: Fri, 02 Sep 2022 09:25:29 +0300

> From: Perry Smith <pedz@easesoftware.com>
> Date: Thu, 1 Sep 2022 18:34:39 -0500
> 
> 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.

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.

> 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.

Michael, WDYT?





reply via email to

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