Question

I'm familiar with how to use inotify to monitor for changes to named files within directories, but I'm currently wondering if it's possible to use it to watch for modifications of a file only known by an opened filehandle. Is such a thing possible?

inotify_add_watch is documented as taking just a pathname, and I don't see any other functions to add such watches.

Failing this, is there some way I can take an open filehandle and convert it somehow back into a pathname, such that I can pass that to inotify?

Edit: Actually it doesn't strictly have to be inotify, I'm just looking for a mechanism to be notified when regular files have been appended to or modified - think tail -f and similar.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top