Subscribe to the file in / sys

Inotify will not activate file changes in /sys- what are the ways to subscribe to changes there?

+3
source share
3 answers

Use the udev and udev rules to receive notification of changes (hardware hotplug, driver downloads, firmware downloads, etc.) that are reflected in / sys.

For more details see http://hackaday.com/2009/09/18/how-to-write-udev-rules/

+1
source

Events that change / sys are usually handled by udev. This way you can add udevd rules for event handling or use libudev to access and monitor sysf. I just found a few lessons here: http://www.signal11.us/oss/udev/

+2

In order to get notifications about file / directory / sys changes, I use 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 the list (fd, event) that has been affected.

+1
source

All Articles