linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* select() / inotify / sysfs
@ 2008-03-18 15:59 Jason
  2008-03-19 21:10 ` Jason
  0 siblings, 1 reply; 2+ messages in thread
From: Jason @ 2008-03-18 15:59 UTC (permalink / raw)
  To: linux-c-programming

All,

I've discovered that my physical environment causes intermittent wifi 
connectivity (drops for a few seconds, then returns).  My program can 
work through this, but needs to know that the connection has been 
interrupted.

I've placed a watch on different files in /sys/class/net/ath0/* and 
found that operstate changes (from 'up' to 'down') when I experience 
these network drops.  So, I used inotify to detect changes to the file 
as a proof of concept:

# inotifywatch -v -r /sys/class/net/ath0/operstate

No go.  It detects when I cat the file, but doesn't detect when the 
kernel changes it (which make sense on an academic note, since it 
doesn't have a value until it's read by userspace).

So, does anyone know of a good (hopefully select() based) method to 
detect this change?  It doesn't have to use sysfs, that's just the 
dragon I'm chasing right now.  ;-)  I'd really prefer not to poll the 
file...

tia,

Jason.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: select() / inotify / sysfs
  2008-03-18 15:59 select() / inotify / sysfs Jason
@ 2008-03-19 21:10 ` Jason
  0 siblings, 0 replies; 2+ messages in thread
From: Jason @ 2008-03-19 21:10 UTC (permalink / raw)
  To: linux-c-programming

Jason wrote:
> All,
> 
> I've discovered that my physical environment causes intermittent wifi 
> connectivity (drops for a few seconds, then returns).  My program can 
> work through this, but needs to know that the connection has been 
> interrupted.
> 
> I've placed a watch on different files in /sys/class/net/ath0/* and 
> found that operstate changes (from 'up' to 'down') when I experience 
> these network drops.  So, I used inotify to detect changes to the file 
> as a proof of concept:
> 
> # inotifywatch -v -r /sys/class/net/ath0/operstate
> 
> No go.  It detects when I cat the file, but doesn't detect when the 
> kernel changes it (which make sense on an academic note, since it 
> doesn't have a value until it's read by userspace).
> 
> So, does anyone know of a good (hopefully select() based) method to 
> detect this change?  It doesn't have to use sysfs, that's just the 
> dragon I'm chasing right now.  ;-)  I'd really prefer not to poll the 
> file...

Update since vger is backup.  I tried netlink also, and it only reports 
IFF_UP changes (I've only tried RTMGRP_LINK/NETLINK_ROUTE so far).  So 
it tells me when I do ifconfig ath0 [up|down], but doesn't trigger when 
operstate changes and the interface is still up (IFF_UP).

Any ideas?

thx,

Jason.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-19 21:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-18 15:59 select() / inotify / sysfs Jason
2008-03-19 21:10 ` Jason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).