Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

inotify doesnt work on /sys and /proc file systems. So how can I monitor a /sys partition file without polling?

share|improve this question
up vote 2 down vote accepted

What kind of polling? Do you mean a sleep/check loop? Or do you mean the poll system call as documented in man 2 poll?

According to a 2009 email from kernel developer Greg KH, the best option is to use select. See man 2 select for details. Note that the poll system call is basically the same as this.

On the other hand, the current inotify FAQ suggests it might work.

Why not try it and find out?

share|improve this answer
I think we can safely assume the OP was working from a shell and he wasn't talking about C functions. Anyway, currently it's still not working for me in /sys files (Linux 3.6.3), I only get OPEN/ACCESS events, but not changes made by the kernel. – tokland May 23 '13 at 17:56
@tokland I'm not aware of any command called inotify? – Mikel May 24 '13 at 1:26
FWIW, inotifywatch from inotify-tools seems to work fine to count changes on /proc/sys on my Linux 3.5.0 system. – Mikel May 24 '13 at 1:35
Mikel, I use inotifywait from inotify-tools. Can you try this in a laptop? inotifywait -m /sys/class/power_supply/BAT0/status. I get I don't get any event when this value changes (unplug/plug the battery). – tokland May 24 '13 at 7:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .