Inotify won't trigger on file-changes in /sys
- what ways are there to subscribe to changes in there?
Asked
Active
Viewed 931 times
4

Reactormonk
- 21,472
- 14
- 74
- 123
3 Answers
2
Events that change /sys are usually handled by udev. So, you can add udevd rules to handle the events or use libudev to access and monitor the sysfs. I just found some tutorial here: http://www.signal11.us/oss/udev/

Jacek Konieczny
- 8,283
- 2
- 23
- 35
1
Use udev and udev rules to get a notification to changes (hardware hotplug, drivers load, firmware load etc.) that are reflected in /sys.
See http://hackaday.com/2009/09/18/how-to-write-udev-rules/ for details

gby
- 14,900
- 40
- 57
1
To be notified on a change on a /sys file or directory, I use the polling objects from python.
import select
poll_objet = select.poll()
fd_object = file("/sys/what_you_want_to_survey", "r")
poll_objet.register(fd_object) # I use the select.POLLPRI | select.POLLERR combination in my code ;)
result = poll_object.poll()
where result is a list of (fd, event) that were touched.

Cédric Julien
- 78,516
- 15
- 127
- 132
-
Why did you called your poll object "poll_objet" without a "c"? – Ikem Krueger Jun 23 '16 at 15:24
-
I used a Python shell and entered the code by hand. As file I used "/home/ikem/operstate". I used a regular Bash shell to change the value by `echo "0">operstate` and `echo "1">operstate`. In the Python shell I printed the value of "result". I wrote a while loop, to refresh and print result on every run, and I got the same pair of values everytime "[3][5]". What am I missing here? – Ikem Krueger Jun 23 '16 at 15:40