Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 3 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.