Open chrisinmtown opened 4 years ago
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.
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.
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 :)
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