Can Linux inotify be used when opening file descriptors?

I know how to use inotify to monitor changes to named files in directories, but now I wonder if it can be used to view changes to a file known only by the open file descriptor. Is it possible?

inotify_add_watch documented as just a path name, and I don't see any other functions to add such a clock.

Otherwise, can you somehow open the open file descriptor and somehow convert it to a path in order to pass this inotify ?

Edit: this doesn't really have to be inotify, I'm just looking for a mechanism to notify when regular files were added or changed - think tail -f and the like.

+4
source share
1 answer

You can use "/ proc / x / fd / y" as the path to inotify_add_watch, where x is your process identifier and y is the file identifier.

+2
source

Source: https://habr.com/ru/post/1415825/


All Articles