inotify_simple icon indicating copy to clipboard operation
inotify_simple copied to clipboard

Extend doc to cover watching a file

Open chrisinmtown opened this issue 4 years ago • 3 comments

Can inotify_simple watch a file? The documentation only mentions monitoring a directory, but the linux kernel call allows monitoring of directories OR files:

https://man7.org/linux/man-pages/man7/inotify.7.html

Maybe this is just a request to extend the documentation slightly :)

Thanks for listening

chrisinmtown avatar Jun 16 '20 16:06 chrisinmtown

Yes, it can, it's just calling the underlying inotify functions fairly directly so it can do everything they can do. The example with a directory is just because there are more interesting events that can happen on a directory!

Point taken that this could be made more obvious in the documentation.

chrisjbillington avatar Jun 16 '20 17:06 chrisjbillington

Just note that it often makes more sense to watch the directory and act on changes associated with the file name you want to watch. In particular, the file may not exist when you want to start watching it so the call will fail. Just watch the directory instead and action appropriately when that file name is added, deleted, or modified.

bulletmark avatar Jun 16 '20 22:06 bulletmark

Thanks @bulletmark but my scenario is watching a configuration file published by Kubernetes from within a running container started by Kubernetes. If that file ain't there on start then nuthin' happens :)

chrisinmtown avatar Aug 03 '20 17:08 chrisinmtown