Java WatchService doesn't work on some folders

最后都变了- 提交于 2019-12-10 12:18:02

问题


I want to use Java 7 WatchService to monitor /proc folder, but that's not working (changes made in the folder are not reported). I've tested other folders such as /home/user/Desktop and /tmp and it works. What could be the reason? Is it because of permissions? /proc is obviously owned by root whereas the other folder is owned by logged in user. The /tmp however is also owned by root, but it works. I'm using this basic implementation to test it.

My OS is Ubuntu 13.10 64bit. Oracle Java 1.7.0_51.


回答1:


It's because /proc isn't a normal filesystem and therefore doesn't support inotify:

https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc https://unix.stackexchange.com/questions/74713/how-frequently-is-the-proc-file-system-updated-on-linux?rq=1



来源:https://stackoverflow.com/questions/22043557/java-watchservice-doesnt-work-on-some-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!