How can I detect changes in / proc / net / files?
I am looking forward to creating a network monitor by looking at the contents of the / proc / net folder. This is my special requirement so that I cannot spoof packets or something like that. My whole source is / proc / net. For example, I can get all active TCP connection data from / proc / net / tcp etc.
The content of these files keeps changing, so I want to read these files all the time, but also I only need to read when they change, that is, if there is no network connected, the contents of the file will not change and I will not 't' need to read them.
I searched for inotify but found no changes in / proc / net / files.
inotifywatch /proc/net/
Continuous polling, I think, will be ineffective. So look for an offer .. Thanks in advance.
source to share
Have you checked the gio libraries? You can add a clock to the open file and specify on which events you get the callback.
https://developer.gnome.org/glib/stable/glib-IO-Channels.html
Also, this might interest you (it seems newer versions have already included this patch):
https://gitorious.org/gnome-essentials/glib/commit/68f9255ec6434b25339cfd6055013e898730d0e7
source to share