On Wed, 2009-11-04 at 11:35 -0500, Martin Dubuc wrote:
Addition of a working version of rfkill in Fedora 12 has been really
welcomed. In my application, I would like to monitor the RF kill
switch to detect when user enables/disables Wi-Fi on the system. I
thought I could use the rfkill executable to do this, using "rfkill
event", piping the output using popen in my process. However, rfkill
outputs the events on standard output, but does not flush every time
it reports an event. When I perform fgets to get the events, I get
nothing. I am wondering if it would be possible to add a fflush on
stdout when events are reported on stdout inside rfkill.
You're probably better off monitoring /dev/rfkill yourself directly (for
now[1]), there's example code in gnome-bluetooth, look at
lib/bluetooth-killswitch.c.
You'd basically just need to change the type of killswitch you're
monitoring.
Cheers
[1]: We'd probably want a D-Busified rfkilld in the future.